Linux itself has a firewall named "Iptables". The Dark One you said is the terminal. Enter the following command in the terminal to open the firewall:
| The code is as follows |
Copy Code |
Chkconfig iptables on |
If the firewall is closed, enter:
| The code is as follows |
Copy Code |
Chkconfig iptables off |
All two of these commands have to be restarted for the system to take effect.
You can use the service command if you do not want to take effect immediately by restarting the system. The disadvantage is that the settings will be lost when you reboot the system.
Firewall turned on:
| The code is as follows |
Copy Code |
| Service Iptables Start |
To turn off the firewall:
| The code is as follows |
Copy Code |
Service Iptables Stop |
To set a switch on some ports in the firewall, modify the edit/etc/sysconfig/iptables file, such as SSH Port 22, which can be added as follows:
When the firewall is turned on, make the following settings, open the relevant port,
Modify the/etc/sysconfig/iptables file and add the following:
| The code is as follows |
Copy Code |
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT |
CentOS Linux firewall configuration and shutdown
Perform the "Setup" command to start the text mode configuration Utility, select "Firewall Configuration" in "Select a tool", then select the "Run Tool" button, the firewall configuration interface appears, set the security level to Disabled, and select OK.
or by command:
| The code is as follows |
Copy Code |
#/sbin/iptables-i input-p tcp–dport 80-j ACCEPT #/sbin/iptables-i input-p tcp–dport 22-j ACCEPT #/etc/rc.d/init.d/iptables Save |
After this reboot the computer, the firewall has opened 80 and 22 ports by default
You should also not reboot the computer here:
| The code is as follows |
Copy Code |
| #/etc/init.d/iptables restart |
To turn off the Firewall service:
To view firewall information:
| The code is as follows |
Copy Code |
#/etc/init.d/iptables status |
To turn off the Firewall service:
| code is as follows |
copy code |
| #/etc/ Init.d/iptables stop |