Roteando o tráfego do OpenVPN através de um roteador TomatoUSB

0

Eu configurei um Tomato USB, no meu segundo roteador (interno). O roteador externo simplesmente encaminha o tráfego VPN para ele e atua como um servidor VPN. Posso conectar-me ao servidor VPN e às redes locais, mas perco a conectividade com a Internet.

Eu sei porque: não estou roteando o tráfego VPN através do gateway. Eu procurei por aí e descobri que o que eu preciso fazer é:

iptables -I FORWARD -i tun0 -o eth0 \
         -s 10.8.0.0/24 -m conntrack --ctstate NEW -j ACCEPT

iptables -I FORWARD -m conntrack --ctstate RELATED,ESTABLISHED \
         -j ACCEPT

iptables -t nat -I POSTROUTING -o eth0 \
          -s 10.8.0.0/24 -j MASQUERADE

Embora no meu caso, eu tenha que mudar tun0 para tun21 e eth0 para br0. No entanto, a versão TomatoUSB que eu tenho, produz este erro:

iptables v1.3.8: Couldn't load match 'conntrack':File not found

AFAIK, esta é uma versão antiga do iptables. Então, como posso rotear e mascarar meu tráfego VPN através do roteador TomatoUSB?

route -n

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.1     0.0.0.0         255.255.255.255 UH    0      0        0 vlan2
10.8.0.2        0.0.0.0         255.255.255.255 UH    0      0        0 tun21
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 vlan2
10.8.0.0        10.8.0.2        255.255.0.0     UG    0      0        0 tun21
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 vlan2

iptables --list

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             anywhere            udp dpt:1194 
DROP       all  --  anywhere             anywhere            state INVALID 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
shlimit    tcp  --  anywhere             anywhere            tcp dpt:ssh state NEW 
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             anywhere            udp spt:bootps dpt:bootpc 
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:1194 
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
           all  --  anywhere             anywhere            account: network/netmask: 192.168.1.0/255.255.255.0 name: lan 
ACCEPT     all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere            state INVALID 
TCPMSS     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
wanin      all  --  anywhere             anywhere            
wanout     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain shlimit (1 references)
target     prot opt source               destination         
           all  --  anywhere             anywhere            recent: SET name: shlimit side: source 
DROP       all  --  anywhere             anywhere            recent: UPDATE seconds: 60 hit_count: 4 name: shlimit side: source 

Chain wanin (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             athena.utopia       tcp dpts:5999:x11-1 
ACCEPT     udp  --  anywhere             athena.utopia       udp dpts:5999:x11-1 
ACCEPT     tcp  --  anywhere             athena.utopia       tcp dpt:3022 
ACCEPT     udp  --  anywhere             athena.utopia       udp dpt:3022 

Chain wanout (1 references)
target     prot opt source               destination         

iptables -t nat -L -n -v

Chain PREROUTING (policy ACCEPT 24 packets, 1296 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   14   588 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:1194 
   40 13755 WANPREROUTING  all  --  *      *       0.0.0.0/0            192.168.0.4         
    0     0 DROP       all  --  vlan2  *       0.0.0.0/0            192.168.1.0/24      

Chain POSTROUTING (policy ACCEPT 8 packets, 576 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   12   912 MASQUERADE  all  --  *      vlan2   10.8.0.0/24          0.0.0.0/0           
    2   152 MASQUERADE  all  --  *      vlan2   10.8.0.0/24          0.0.0.0/0           
 6781  490K MASQUERADE  all  --  *      vlan2   0.0.0.0/0            0.0.0.0/0           
    0     0 SNAT       all  --  *      br0     192.168.1.0/24       192.168.1.0/24      to:192.168.1.1 
    0     0 MASQUERADE  all  --  *      vlan2   0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 8 packets, 576 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain WANPREROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DNAT       icmp --  *      *       0.0.0.0/0            0.0.0.0/0           to:192.168.1.1 
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpts:5999:6001 to:192.168.1.130 
    0     0 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpts:5999:6001 to:192.168.1.130 
    2   128 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:22 to:192.168.1.130:3022 
    0     0 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:22 to:192.168.1.130:3022 
    
por Alex 27.10.2015 / 11:58

1 resposta

1

Não tenho certeza se entendi o seu problema, então não sei se as três regras do iptables são uma solução para ele. No entanto, na medida em que as três regras per se estão em causa, você realmente não precisa dos dois primeiros, você pode substituí-los com a regra única:

    iptables -I FORWARD -j ACCEPT

A terceira regra é realmente importante, mas, felizmente, você não precisa do módulo conntrack para ela. Estou um pouco surpreso, mas o Tomato não tem um módulo comum.

Editar :

olhando para sua tabela de roteamento, parece-me que sua interface WAN ( isto é, , aquela que está falando com a internet, não com a sua LAN) é vlan2 . Neste caso, sua terceira regra de iptables deve ser:

   iptables -t nat -I POSTROUTING -o vlan2 -s 10.8.0.0/24 -j MASQUERADE

Se estou enganado, pls substitui o nome da interface WAN por vlan2 .

    
por 27.10.2015 / 12:31