Iptables以及Firewall
转发流量
wget -N –no-check-certificate https://wp.jinzz.cc/wp-content/uploads/iptables-pf.sh && chmod +x iptables-pf.sh
bash iptables-pf.sh
Centos开始采用Firewall,不过也是基于Iptables的基础_
Iptables
配置文件位置 /etc/sysconfig/iptables
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT
Firewall
操作命令范例
firewall-cmd –permanent –zone=public –add-port=80/tcp //添加开放80端口
firewall-cmd –permanent –zone=public –remove-port=80/tcp //移除开放80端口
另外配置方式可以间接修改/etc/firewalld/zones/public.xml文件
firewall-cmd –permanent –zone=public –add-forward-port=port=2333:proto=tcp:toport=2333:toaddr=192.168.0.152 //端口转发
firewall-cmd –complete-reload //保存并且重新启动防火墙
启动防火墙
systemctl start firewalld.service
关闭防火墙
systemctl stop firewalld.service
重新启动防火墙
systemctl restart firewalld.service
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Jindom's Blog!