天天看点

linux 下添加防火墙端口方法

在/etc/sysconfig下找到iptables文件,打开后进行编辑,添加一行:

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

重新启动防火墙

/etc/rc.d/init.d/iptables restart

使用iptables -L -n 查看现在的防火墙设置,果然发现成功了。

ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80

ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443

ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:3306

继续阅读