Wiregurad - jak nastavit routování

Wiregurad - jak nastavit routování
« kdy: 14. 12. 2020, 07:52:20 »
Ahoj,

na virtuálním serveru (VS, 10.1.1.1) mám nainstalovaný Wireguard ke kterému je připojeno několik peeru a vše funguje tak jak má.

Nyní bych však potřeboval nastavit routování pro jedno konkrétní zařízení (DeviceA, 10.1.1.5) tak, aby jeho veškerý provoz směřoval přes jiného peera (Turris, 10.1.1.10)

Zatím jsem na serveru vytvořil novou routovací tabulku 'custom'

A přidal do ni následujíci pravidla
Kód: [Vybrat]
ip rule add from 10.1.1.5 table custom
ip route add default via 10.1.1.10 dev wg0 table custom

Nicméně teď uplně nevím jak pokračovat, protože tcptraceroute na DeviceA končí na VS
Kód: [Vybrat]
Tracing the path to 77.75.75.172 on TCP port 443 (https), 30 hops max
 1  10.1.1.1  17.309 ms  15.260 ms  15.863 ms
 2  10.1.1.1  15.743 ms !H * *

Nastavení peerů ve Wireguardu
Kód: [Vybrat]
[Peer]
PublicKey = VEREJNY_KLIC_DEVICEA
AllowedIPs = 10.1.1.5/32
Endpoint = IP:PORT

[Peer]
PublicKey = VEREJNY_KLIC_TURRIS
AllowedIPs = 10.1.1.10/32
Endpoint =  IP:PORT

Nastavení iptables na VS
Kód: [Vybrat]
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
SNAT       all  --  10.1.1.0/24        anywhere             to:VERJENA_IP_SERVERU

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Díky moc všem za nakopnutí jak pokračovat.


Re:Wiregurad - jak nastavit routování
« Odpověď #1 kdy: 14. 12. 2020, 10:23:09 »
Mas zapnuty forwarding a zaroven povoleny na firewallu?

Re:Wiregurad - jak nastavit routování
« Odpověď #2 kdy: 14. 12. 2020, 10:47:24 »
Mas zapnuty forwarding a zaroven povoleny na firewallu?

Forwarding je zapnuty, jaky firewall mas na mysli? Na VS je jen jedno pravidlo SNAT (viz muj prvni prispevek)

Re:Wiregurad - jak nastavit routování
« Odpověď #3 kdy: 14. 12. 2020, 12:43:39 »
Citace
The keyword allowed-ips is a list of addresses that will get routed to the peer. Make sure to specify at least one address range that contains the WireGuard connection's internal IP address(es).
Kód: [Vybrat]

[Interface]
Address = 10.1.1.5/...
PrivateKey = DeviceA


[Peer]
PublicKey = VEREJNY_KLIC
AllowedIPs = 0.0.0.0/0
Endpoint = IP:PORT

routování dořešit na konci tunelu.
« Poslední změna: 14. 12. 2020, 12:53:09 od drobax »

Re:Wiregurad - jak nastavit routování
« Odpověď #4 kdy: 14. 12. 2020, 12:54:58 »
Citace
The keyword allowed-ips is a list of addresses that will get routed to the peer. Make sure to specify at least one address range that contains the WireGuard connection's internal IP address(es).
Kód: [Vybrat]
[Peer]
PublicKey = VEREJNY_KLIC_DEVICEA
AllowedIPs = 0.0.0.0/0
Endpoint = IP:PORT

To urcite ne, nechci routovat veskery provoz z VS pres DeviceA :)


Re:Wiregurad - jak nastavit routování
« Odpověď #5 kdy: 14. 12. 2020, 13:00:51 »
Citace
The keyword allowed-ips is a list of addresses that will get routed to the peer. Make sure to specify at least one address range that contains the WireGuard connection's internal IP address(es).
Kód: [Vybrat]
[Peer]
PublicKey = VEREJNY_KLIC_DEVICEA
AllowedIPs = 0.0.0.0/0
Endpoint = IP:PORT

To urcite ne, nechci routovat veskery provoz z VS pres DeviceA :)

Ano upsal jsem se. To patří na Device A. Ne na VPS.

Re:Wiregurad - jak nastavit routování
« Odpověď #6 kdy: 14. 12. 2020, 13:13:37 »
Citace
The keyword allowed-ips is a list of addresses that will get routed to the peer. Make sure to specify at least one address range that contains the WireGuard connection's internal IP address(es).
Kód: [Vybrat]

[Interface]
Address = 10.1.1.5/...
PrivateKey = DeviceA


[Peer]
PublicKey = VEREJNY_KLIC
AllowedIPs = 0.0.0.0/0
Endpoint = IP:PORT

routování dořešit na konci tunelu.

DeviceA je takhle presne nastavene, ted prave resim to routovani VS kdy se mi to routovani nedari nastavit.