我在configuration我的ubuntu服务器防火墙方面有一些困难…我的情况是这样的:
eth0 – >互联网
eth1 – > lan1
eth2 – > lan2
我希望来自lan1的客户端不能与来自lan2的客户端通信,除了某些特定的服务。 例如,我希望lan1中的客户端可以在lan2中ssh客户端,但仅限于此。 任何其他通信是被禁止的。
所以,我把这个规则添加到iptables:
#Block all traffic between lan, but permit traffic to internet iptables -I FORWARD -i eth1 -o ! eth0 -j DROP iptables -I FORWARD -i eth2 -o ! eth0 -j DROP # Accept ssh traffic from lan1 to client 192.168.20.2 in lan2 iptables -A FORWARD -i eth1 -o eth2 -p tcp --dport 22 -d 192.168.20.2 -j ACCEPT
这没有奏效。 做iptables -L FORWARD -vi看:
Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 33 144 DROP all -- eth1 !eth0 anywhere anywhere 0 0 DROP all -- eth2 !eth0 anywhere anywhere 23630 20M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 0 0 ACCEPT all -- eth1 any anywhere anywhere 175 9957 ACCEPT all -- eth1 any anywhere anywhere 107 6420 ACCEPT all -- eth2 any anywhere anywhere 0 0 ACCEPT all -- pptp+ any anywhere anywhere 0 0 ACCEPT all -- tun+ any anywhere anywhere 0 0 ACCEPT tcp -- eth1 eth2 anywhere server2.lan tcp dpt:ssh
所有数据包都被丢弃,最后一条规则的数据包数为0。
我如何修改我的configuration? 谢谢。
问候Marco
您的DROP在链的前端(并且将被首先处理)。 您希望在允许使用SSH规则的SSH访问规则之后放置DROP。
像这样的东西应该工作:
#Accept ssh traffic from lan1 to client 192.168.20.2 in lan2 iptables -A FORWARD -i eth1 -o eth2 -p tcp --dport 22 -d 192.168.20.2 -j ACCEPT #Block all traffic between lan, but permit traffic to internet iptables -A FORWARD -i eth1 -o ! eth0 -j DROP iptables -A FORWARD -i eth2 -o ! eth0 -j DROP
(使用-A将这些规则附加到链的末尾)