CentOS 7.X默认使用的是firewall作为防火墙,如果你想用CentOS主机做一个服务器和其他主机交互,socket通信什么的,不把默认防火墙关掉是不行的。那我们来看下如何在一台新装CentOS 7.X的主机关闭默认防火墙。
一.关闭默认firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
二.开启iptables
yum -y install iptables-services #安装iptables
systemctl enable iptables #设置开机自启
systemctl enable iptables.service #两个都执行
之后,你就可以写socket程序和CentOS主机交互了。