个人工具
登录
查看“IptablesHowTo”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“IptablesHowTo”的源代码
来自Ubuntu中文
←
IptablesHowTo
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
=== Blocking Traffic 阻断通信 === Once a decision is made about a packet, no more rules affect it. As our rules allowing ssh and web traffic come first, as long as our rule to block all traffic comes after them, we can still accept the traffic we want. All we need to do is put the rule to block all traffic at the end. The -A command tells iptables to append the rule at the end, so we'll use that again. 对每一个报文,iptables依次测试每一条规则,看报文与规则是否相匹配。一旦找到一条匹配的规则,就根据此规则中指定的行动,对报文进行处置,而对后面的规则不再进行测试。因此,如果我们在规则表的末尾添加一条规则,让iptables丢弃所有报文,但由于有了前面几条规则,ssh和web的正常通信不会受到影响。 <pre><nowiki> sudo iptables -A INPUT -j DROP # iptables -A INPUT -j DROP # iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ACCEPT tcp -- anywhere anywhere tcp dpt:www DROP all -- anywhere anywhere </nowiki></pre> Because we didn't specify an interface or a protocol, any traffic for any port on any interface is blocked, except for web and ssh. 在上面的规则中,没有明确指出针对哪个接口或哪种协议使用此规则,所以从每个接口接收到的除ssh和web之外的所有报文都会被丢弃。
返回至
IptablesHowTo
。