我试图在教堂的WRT54GL上运行dd-wrt v24设置防火墙。 在设置防火墙方面,我还没find很多好的指南,而且这些路由器似乎还不够新近。
基本上,我想设置防火墙阻止非必要端口上的所有传入stream量,限制某些本地计算机访问文件服务器,并阻止几个传出端口。
我已经尝试与fwbuilder(防火墙生成器)搞乱,但没有运气。 我可以将我的更改提交到防火墙,但似乎无法让他们实际工作。
任何人都可以帮忙?
我不能给你一个确切的答案,但下面应该帮助,并给你一个粗略的想法。
停止本地客户端访问文件服务器可能是不可能的,如果他们是在相同的networking(即在同一个IPnetworking和相同的物理段),因为数据包将不需要穿越路由器之间旅行。 如果他们确实需要通过路由器,那么我已经包含了一个我认为会有所帮助的规则。
我不是那个发行版的家庭,所以我不确定你应该把这些规则放在哪里。
#Add these rules once iptables -A FORWARD -j INPUT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p icmp --icmp-type any -j ACCEPT iptables -A INPUT -p 50 -j ACCEPT iptables -A INPUT -p 51 -j ACCEPT iptables -A INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #for each incoming tcp service you want to allow add one of these: iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport <allowed_port> -j ACCEPT #for each incoming udp service you want to allow add one of these: iptables -A INPUT -m state --state NEW -m udp -p udp --dport <allowed_port> -j ACCEPT #for each local client that should not have fileserver access add one of these: iptables -A INPUT -s <banned_local_ip> -d <filesrever> -j REJECT #add these once iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited # if you only wanted to block the outgoing access for a given local IP to an # external service then you add one of these for each local client and external # service combination iptables -A OUTPUT -s <local_banned_IP> --dport <disallowed_port> -j REJECT #for each outgoing service you want to block to all local host add one of these: # this will block the service for every host on the network iptables -A OUTPUT --dport <disallowed_port> -j REJECT #add this once to allow all other outgoing iptables -A OUTPUT -j ALLOW
如果文件服务器是一个Linux主机,那么只需在文件服务器上放置iptables规则就可以拒绝你不想访问的本地主机。
这个被认为是“iptables圣经”,它将涵盖你所有的需求。
正如它所说的,如果你在理解任何事情时遇到麻烦,可能是由于缺乏一般的networking知识,你可以使用这本被认为是“networking圣经”来改进的书。
这个问题和答案需要对中/高级别的iptables有所了解。 我不能给出一个“开箱即用”的解决scheme,但是我可以给出几行的例子,从wrt54gl的openwrt几乎打开一个防火墙的例子。
在这个例子中,列出的端口是被允许的,任何其他的被阻塞:
不要盲目粘贴! 这可以locking你:
#iptables -A forwarding_rule -i br-lan -p tcp -m multiport --dports port,port,port -j ACCEPT #iptables -A forwarding_rule -i br-lan -j DROP
这些行来自wifi路由器上的/etc/firewall.user文件。
请在更换东西前进行备份!
请准备好重写固件!
请通过ssh或http留下后门,以防这些不起作用。