Alt ağ trafiğini farklı bir ağ geçidine yeniden yönlendirme


0

Bir OpenVPN istemcisini çalıştıran yönlendiriciye (192.168.1.1'de) bağlı 192.168.1.5'te bir Debian Jessie kutusu var (aslında bu kurulumu kullanan bir Pi'dir . yani, Pi yönlendiricinin DHCP'sini kullanıyor).

LAN istemcileri, ağ geçidi olarak 192.168.1.5 kullanacak şekilde ayarlandığında, istenildiği gibi VPN'dedirler.

İhtiyacım olan, 192.168.1.128/25 dahilindeki LAN istemcilerinin IP'leri yönlendiricinin DHCP'si tarafından ayarlandığında ve ağ geçidi 192.168.1.1 olduğunda bile tüm trafiklerinin 192.168.1.5'e yönlendirilmesini sağlamak . Başka bir deyişle, 192.168.1.128/25 içindeki müşteriler, ağ geçitleri 192.168.1.5 idi.

Yönlendiricinin bunu yapmak için yapması gereken iptablesve / veya route addkurulumu nedir (yönlendirici Domates 3.4-138 kullanıyor)? Bunlar yönlendirici ayarları:

iptables -t nat -L -n

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
WANPREROUTING  all  --  0.0.0.0/0            wan_ip
upnp       all  --  0.0.0.0/0            wan_ip

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0
SNAT       all  --  192.168.1.0/24       192.168.1.0/24       to:192.168.1.1
SNAT       all  --  172.16.1.0/24        172.16.1.0/24        to:172.16.1.1

Chain WANPREROUTING (1 references)
target     prot opt source               destination
DNAT       icmp --  0.0.0.0/0            0.0.0.0/0            to:192.168.1.1
DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 to:192.168.1.1:443
DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:2222 to:192.168.1.5:22
DNAT       all  --  0.0.0.0/0            0.0.0.0/0            to:192.168.1.4

Chain pupnp (0 references)
target     prot opt source               destination

Chain upnp (1 references)
target     prot opt source               destination
DNAT       udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:55355 to:192.168.1.130:55355
DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:55355 to:192.168.1.130:55355
DNAT       udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:5353 to:192.168.1.48:5353
DNAT       udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:4500 to:192.168.1.48:4500

iptables -L

Chain INPUT (policy DROP)
target     prot opt source               destination
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     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https

Chain FORWARD (policy DROP)
target     prot opt source               destination
           all  --  anywhere             anywhere            account: network/netmask: 192.168.1.0/255.255.255.0 name: lan
           all  --  anywhere             anywhere            account: network/netmask: 172.16.1.0/255.255.255.0 name: lan1
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere             state INVALID
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
DROP       all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere
wanin      all  --  anywhere             anywhere
wanout     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
upnp       all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             SIP-Device

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 upnp (1 references)
target     prot opt source               destination
ACCEPT     udp  --  anywhere             client-1                udp dpt:55355
ACCEPT     tcp  --  anywhere             client-1                tcp dpt:55355
ACCEPT     udp  --  anywhere             client-2          udp dpt:mdns
ACCEPT     udp  --  anywhere             client-2          udp dpt:4500

Chain wanin (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             *Pi*               tcp dpt:ssh

Chain wanout (1 references)
target     prot opt source               destination

rota

(yönlendirici WAN modeminin arkasına oturur)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
modem.ip.0.1    *               255.255.255.255 UH    0      0        0 vlan2
192.168.1.0     *               255.255.255.0   U     0      0        0 br0
172.16.1.0      *               255.255.255.0   U     0      0        0 br1
modem.ip.0.0    *               255.255.224.0   U     0      0        0 vlan2
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         modem.ip.0.1    0.0.0.0         UG    0      0        0 vlan2

Yanıtlar:


2

DHCP tarafından sağlanan varsayılan rotayı (a / 0 olan) geçersiz kılmanın hızlı bir yolu, VPN ağ geçidine iki / 1 yol eklemektir:

rota -n add -net 0.0.0.0 192.168.1.5 128.0.0.0

rota -n eklenti -net 128.0.0.0 192.168.1.5 128.0.0.0

DHCP tarafından sağlanan varsayılan rota yerinde kalsa da, / 1'lerden biri IPv4 trafiği için daha kısa önekleri nedeniyle tercih edilecektir.

Şu anda bu hack kavramının bir kanıtı olarak kullanıyorum; Hala çevrimiçiyim ve bir tablo sorgusu / 1 yolunun kullanılmakta olduğunu gösteriyor.

[nevin-mac-mini: ~] root # rota -n eklenti -net 0.0.0.0 192.168.2.1 128.0.0.0
net 0.0.0.0 ekleyin: ağ geçidi 192.168.2.1
[nevin-mac-mini: ~] kök # rota -n eklenti -net 128.0.0.0 192.168.2.1 128.0.0.0
net 128.0.0.0 ekleyin: ağ geçidi 192.168.2.1
[nevin-mac-mini: ~] root # netstat -rn
Yönlendirme tabloları

İnternet:
Hedef Ağ Geçidi Bayrakları Refs Kullanım Netif Expire
0/1 192.168.2.1 UGSc 3 0 en0
varsayılan 192.168.2.1 UGSc 4 0 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 1 6576 01
128.0 / 1 192.168.2.1 UGSc 1 0 en0
...
[nevin-mac-mini: ~] root # güzergahı -n 200.200.200.200
   Güzergah: 200.200.200.200
Hedef: 128.0.0.0
       maske: 128.0.0.0
    ağ geçidi: 192.168.2.1
  arayüz: en0
      bayraklar: 
 recvpipe sendpipe ssthresh rtt, msec rttvar atlama sayısının süresi doluyor
       0 0 0 0 0 0 1500 0 
[nevin-mac-mini: ~] kök no. 

Takip ettiğimden emin değilim. Bu rotaları Pi'ye ekle?
— Gaia

Bunları DHCP tarafından sağlanan .1 aygıtı yerine .5 ana bilgisayarını ağ geçidi olarak kullanmak isteyen herhangi bir cihaza ekleyin.
— Nevin Williams
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.