iptables firewall to stop and start basic operations
iptables firewall is commonly used before centos7, use a firewall on centos7
Firewall basic operations:
# 查询防火墙状态
service iptables status
# 关闭防火墙
service iptables stop
# 开启防火墙
service iptables start
# 重启防火墙
service iptables restart
# 永久关闭防火墙
chkconfig iptables off
# 永久关闭后开启防火墙
chkconfig iptables on
# 查询当前iptables的规则
iptables -L --line-numbers
Open port and close port
On opening and closing the port, we here in the form of editing configuration files, configuration file is / etc / sysconfig / iptables
Add a line in the configuration file
# 开放端口
-A INPUT -p tcp --dport 22 -j ACCEPT
# 关闭端口
-A INPUT -p tcp --dport 22 -j DROP