linux 防火墙 终端批改

linux 防火墙 终端修改

之前一直在图形用户界面修改的防火墙端口。这次因为某台服务器没有鼠标键盘,于是远程登录在终端修改。

?

?

[root@localhost ~]# vi /etc/sysconfig/iptables

?

添加一行使其开放5433端口。

?

?

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

?

然后重启服务使改动生效

?

[root@localhost ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter nat      [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

?

————————————————————————-

1 服务的开启和关闭,这是永久性的,下次重启防火墙不会激活
开启: chkconfig iptables on
关闭: chkconfig iptables off

2 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop

3防火墙开启时,开启指定端口

vim /etc/sysconfig/iptables

修改/etc/sysconfig/iptables 文件,添加以下内容:

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

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

端口号自己更改,tcp/udp也许要自己更改.

?

?

?

QUOTE:
修改iptables时一定要小心,有时候改错了,可能会进不去系统,

所以建议无特别需要还是不要修改iptables,在图形界面下配置比较安全

?

?

?

?

?

linux 防火墙 终端批改

相关文章:

你感兴趣的文章:

标签云: