In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of opening and closing the firewall by linux". In the daily operation, I believe that many people have doubts about the method of opening and closing the firewall by linux. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to turn on and off the firewall by linux". Next, please follow the editor to study!
In linux, you can use the "chkconfig iptables on;" command to permanently turn on the firewall and the "chkconfig iptables off;" command to permanently turn off the firewall; both commands take effect after reboot.
The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
Enable and disable firewall permanently: chkconfig iptables on; (effective after reboot)
Shutdown: chkconfig iptables off; (effective after restart)
Detailed explanation of usage
Command:
Chkconfig-level 2345 iptables off or chkconfig iptables off where 2345 represents "execution level"
Level 0 indicates that the computer is turned off
Level 1 means: single user mode
Level 2 means: multi-user command line mode without network connection
Level 3 means: multi-user command line mode with network connection
Level 4 means: not available
Level 5 means: multi-user mode with graphical interface
Level 6 means: restart
1 service way to turn on and off the firewall temporarily
View firewall status:
[root@centos6 ~] # service iptables statusiptables: firewall is not running.
Turn on the firewall (effective immediately, invalidate after restart):
[root@centos6 ~] # service iptables start disable the firewall (effective immediately and expire after restart):
[root@centos6 ~] # service iptables stop (Note): allow a port to be configured through the firewall
When the firewall is enabled, make the following settings, open the relevant port, modify the / etc/sysconfig/iptables file, and add the following:
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT # allows port 80 to pass through the firewall
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT # allow port 3306 to pass through the firewall
Note: many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start
The correct thing should be added to the bottom of the default port 22 rule
Two ways of iptables
Enter the init.d directory first, and use the following command:
[root@centos6] # cd / etc/init.d/ [root@centos6 init.d] # and then
View firewall status:
[root@centos6 init.d] # / etc/init.d/iptables status temporarily disable the firewall:
[root@centos6 init.d] # / etc/init.d/iptables stop restart iptables:
[root@centos6 init.d] # / etc/init.d/iptables restart at this point, the study on "how to turn on and off firewalls in linux" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.