Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92138548
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-23 08:24:22

  来源:赛迪网    作者:sixth

在远程putty到linux主机上首次做iptables规则时需按以下步骤,以免造成远程断开再也登不了远程linux主机的麻烦.

1.清除原有filter规则.

[root@linux ~]# iptables -F 清除预设表filter中的所有规则链的规则

[root@linux ~]# iptables -X 清除预设表filter中使用者自定链中的规则

2.清除原有filter规则后的信息应为下面的样子

[root@linux ~]# iptables -L -n

Chain INPUT (policy ACCEPT)

target prot opt source destination

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

3.保存所做的修改和重启iptables

[root@linux ~]# /etc/rc.d/init.d/iptables save

[root@linux ~]# service iptables restart

4.添加远程ssh端口

[root@linux ~]#iptables -A INPUT -p tcp --dport 22 -j ACCEPT

[root@linux ~]#iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT

5.设定预设规则

[root@linux ~]# iptables -p INPUT DROP

[root@linux ~]# iptables -p OUTPUT ACCEPT

[root@linux ~]# iptables -p FORWARD DROP

6.再次保存所做的修改和重启iptables

[root@linux ~]# /etc/rc.d/init.d/iptables save

[root@linux ~]# service iptables restart

大功告成一半,接着可以根据自己需要来设置添加规则。

阅读(307) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~