CentOS 7.0关闭服务器的防火墙服务命令
1、直接关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
2、设置 iptables service【安装了就忽视】
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则自己的规则 ,
添加到配置文件里面的“A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8088-j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21-j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2181-j ACCEPT
....
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
最后重启系统使设置生效即可。
查看到iptables服务的当前状态
service iptables status
关闭服务器的防火墙服务命令
# service iptables stop
开启服务器的防火墙服务命令
# service iptables start
编辑和开启防火墙相应端口命令
# vim /ect/sysconfig/iptables
查看端口是否被占用,查看端口命令
# netstat -pan|gerp 8080
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!