关闭防火墙CentOS7、RedHat7之前的Linux发行版防火墙开启关闭(iptables):立即生效,重启无效#openserviceiptablesstart#closeserviceiptablesstoprestart生效#openchkconfigiptableson#ClosechkconfigiptablesoffCentOS7、RedHat7之后的Linux发行版开启和关闭防火墙(firewall):systemctlstopfirewalld.service开启端口CentOS7、RedHat7之前的Linux发行版开启端口#命令模式开启5212端口命令#打开5212端口接收数据/sbin/iptables-IINPUT-ptcp--dport5212-jACCEPT#打开5212端口发送数据/sbin/iptables-IOUTPUT-ptcp--dport5212-jACCEPT#Save配置/etc/rc.d/init.d/iptablessave#重启防火墙服务/etc/rc.d/init.d/iptablesrestart#查看是否开启成功/etc/init.d/iptablesstatusCentOS后7和RedHat7Linux发行版开放端口firewall-cmd--zone=public--add-port=5121/tcp--permanent#--zonescope#--add-port=5121/tcp添加端口,格式为:port/communicationProtocol#--permanent永久生效,不带此参数重启后失效
