linux防火墙

CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services #安装

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。


iptables配置方法

使用iptables -L查看防火墙设置

service   iptables status 查询防火墙状态

service iptables stop 停止

service iptables start 启动

service iptables restart 重启

chkconfig   iptables off 永久关闭

chkconfig   iptables on 永久关闭后启动

/etc/sysconfig/iptable 配置文档


添加规则

iptables -t nat -A PREROUTING --dst 62.210.220.213 -p tcp --dport 2133 -j DNAT --to-destination 62.210.18.26:21

iptables -t nat -A POSTROUTING --dst 62.210.18.26 -p tcp --dport 21 -j SNAT --to-source 62.210.220.213

将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389

(主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389)

做的顺序,先关闭防火墙,再编辑防火墙,最后再启动防火墙

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容