Eu tenho duas inerfaces no meu roteador com tomate firme: br0 e vlan4. br0 está na sub-rede 192.168.0.0/16 e vlan4 na sub-rede 10.0.1.0/24. Como não quero os serviços de rede diferentes em br0 disponíveis no vlan4, adicionei esta regra de firewall:
iptables -I INPUT -i vlan4 -j ACCEPT;
iptables -I FORWARD -i vlan4 -o vlan2 -m state --state NEW -j ACCEPT;
iptables -I FORWARD -i br0 -o vlan4 -j DROP;
vlan2 é minha WAN (acesso à internet).
O problema que eu quero resolver é que eu quero fazer um host da rede 192.168.0.0/16 (br0), que tem ip 192.168.0.50, disponível no vlan4 (10.0.1.0/24). Apenas esse host deve estar disponível no vlan4 (e todos os outros hosts no br0 devem estar inacessíveis). Quais regras de firewall podem ser usadas para fazer isso?
Editar 1:
Saída de iptables -nvL FORWARD
:
Chain FORWARD (policy DROP 4 packets, 204 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- vlan4 192.168.0.50 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- vlan4 ppp0 0.0.0.0/0 0.0.0.0/0 state NEW
229 13483 ACCEPT all -- vlan4 vlan2 0.0.0.0/0 0.0.0.0/0 state NEW
0 0 DROP all -- br0 vlan3 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- vlan3 ppp0 0.0.0.0/0 0.0.0.0/0 state NEW
67 3405 ACCEPT all -- vlan3 vlan2 0.0.0.0/0 0.0.0.0/0 state NEW
0 0 ACCEPT all -- br0 br0 0.0.0.0/0 0.0.0.0/0
34 1360 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
758 40580 TCPMSS tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
11781 2111K restrict all -- * vlan2 0.0.0.0/0 0.0.0.0/0
26837 19M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 wanin all -- vlan2 * 0.0.0.0/0 0.0.0.0/0
287 15927 wanout all -- * vlan2 0.0.0.0/0 0.0.0.0/0
283 15723 ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0
0 0 upnp all -- vlan2 * 0.0.0.0/0 0.0.0.0/0
Saída de iptables -t nat -nvL PREROUTING
:
Chain PREROUTING (policy ACCEPT 6887 packets, 526K bytes)
pkts bytes target prot opt in out source destination
855 83626 WANPREROUTING all -- * * 0.0.0.0/0 222.228.137.210
0 0 DROP all -- vlan2 * 0.0.0.0/0 192.168.0.0/16
0 0 DNAT udp -- * * 192.168.0.0/16 !192.168.0.0/16 udp dpt:53 to:192.168.0.1
A saída de ip route show
:
222.228.137.209 dev vlan2 scope link
222.228.137.208/29 dev vlan2 proto kernel scope link src 222.228.137.210
10.0.0.0/24 dev vlan3 proto kernel scope link src 10.0.0.1
10.0.1.0/24 dev vlan4 proto kernel scope link src 10.0.1.1
192.168.1.0/24 dev br0 proto kernel scope link src 192.168.1.252
192.168.0.0/16 dev br0 proto kernel scope link src 192.168.0.1
127.0.0.0/8 dev lo scope link
default via 222.228.137.209 dev vlan2