Nie używałem nigdy wireguarda musiałem sobie to przeklikać więc zrobiłem sobie twoją sieć na paru wirtualkach.
1.>>>>>
Wiec rozumiem że z Owrt Asus chcesz mieć połączenie do lan 192.168.100.0/24 i 192.168.101.0/24 ale cały internet ma przechodzić przez lte
w /etc/config/network w mniej mniej więcej to musi być tak
config interface 'wg0'
option proto 'wireguard'
option private_key 'yJA80gcARrR8m5QgTJIspgVIGkgBX8GwAso0emPQB2I='
list addresses '10.8.1.4/24'
config wireguard_wg0
option public_key 'yrIm5LB5Hcs7hVRKXIs86/x3g+LhItwyJCU8+/FStmU='
option route_allowed_ips '1'
list allowed_ips '10.8.1.0/24 192.168.100.0/24 192.168.101.0/24'
option endpoint_host '172.16.11.11'
option endpoint_port '13231'
option persistent_keepalive '25'
option description 'OW_Asus'
----
list allowed_ips '10.8.1.0/24 192.168.100.0/24 192.168.101.0/24' ta linijka robi za push jaki znasz z openvpn > list push 'route 192.168.100.0 255.255.255.0'
---
dzięki niej masz w tablicy routingu takie trasy:
root@OW_Asus:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 100.110.10.1 0.0.0.0 UG 0 0 0 eth1
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
100.110.10.0 0.0.0.0 255.255.255.248 U 0 0 0 eth1
172.16.11.11 100.110.10.1 255.255.255.255 UGH 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
192.168.101.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
root@OW_Asus:~# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UNKNOWN qlen 1000
link/ether 00:0c:29:75:9b:13 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN qlen 1000
link/ether 00:0c:29:75:9b:1d brd ff:ff:ff:ff:ff:ff
inet 100.110.10.2/29 brd 100.110.10.7 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe75:9b1d/64 scope link
valid_lft forever preferred_lft forever
18: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 00:0c:29:75:9b:13 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global br-lan
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe75:9b13/64 scope link
valid_lft forever preferred_lft forever
19: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN qlen 1000
link/[65534]
inet 10.8.1.4/24 brd 10.8.1.255 scope global wg0
valid_lft forever preferred_lft forever
a więc:
root@OW_Asus:~# ping 10.8.1.1
PING 10.8.1.1 (10.8.1.1): 56 data bytes
64 bytes from 10.8.1.1: seq=0 ttl=64 time=0.930 ms
64 bytes from 10.8.1.1: seq=1 ttl=64 time=0.955 ms
64 bytes from 10.8.1.1: seq=2 ttl=64 time=0.904 ms
64 bytes from 10.8.1.1: seq=3 ttl=64 time=0.961 ms
64 bytes from 10.8.1.1: seq=4 ttl=64 time=1.007 ms
^C
--- 10.8.1.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.904/0.951/1.007 ms
root@OW_Asus:~# traceroute 10.8.1.1
traceroute to 10.8.1.1 (10.8.1.1), 30 hops max, 46 byte packets
1 10.8.1.1 (10.8.1.1) 0.657 ms 0.635 ms 0.580 ms
tunel wg działa
root@OW_Asus:~# ping 192.168.101.1
PING 192.168.101.1 (192.168.101.1): 56 data bytes
64 bytes from 192.168.101.1: seq=0 ttl=64 time=0.942 ms
64 bytes from 192.168.101.1: seq=1 ttl=64 time=1.045 ms
64 bytes from 192.168.101.1: seq=2 ttl=64 time=0.934 ms
^C
--- 192.168.101.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.934/0.973/1.045 ms
widzę adres serwera od sieci lokalnej
root@OW_Asus:~# traceroute 192.168.101.254
traceroute to 192.168.101.254 (192.168.101.254), 30 hops max, 46 byte packets
1 10.8.1.1 (10.8.1.1) 0.005 ms 0.473 ms 0.538 ms
2 192.168.101.254 (192.168.101.254) 1.088 ms 1.057 ms 1.062 ms
i z wxp w sieci asusa do sieci MikroTik 192.168.1.120>192.168.101.254
C:\Documents and Settings\Administrator>ping 192.168.101.254
Pinging 192.168.101.254 with 32 bytes of data:
Reply from 192.168.101.254: bytes=32 time=2ms TTL=126
Reply from 192.168.101.254: bytes=32 time=1ms TTL=126
Reply from 192.168.101.254: bytes=32 time=1ms TTL=126
Reply from 192.168.101.254: bytes=32 time=1ms TTL=126
Ping statistics for 192.168.101.254:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Documents and Settings\Administrator>tracert 192.168.101.254
Tracing route to 192.168.101.254 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms OW_Asus.lan [192.168.1.1]
2 1 ms 1 ms 1 ms 10.8.1.1
3 1 ms 1 ms 1 ms 192.168.101.254
Trace complete.
2.>>>>>>>>>>>>
Jeżeli chcesz żeby przez tunel przechodziło wszystko i wychodziło przez brame Mikrotika to
list allowed_ips '0.0.0.0/0'
root@OW_Asus:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 wg0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
100.110.10.0 0.0.0.0 255.255.255.248 U 0 0 0 eth1
172.16.11.11 100.110.10.1 255.255.255.255 UGH 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
C:\Documents and Settings\Administrator>tracert 1.1.1.1
Tracing route to one.one.one.one [1.1.1.1]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms OW_Asus.lan [192.168.1.1]
2 1 ms 1 ms 1 ms 10.8.1.1
3 1 ms 1 ms 1 ms 172.16.11.2
4 * * * Request timed out.
5 ^C
C:\Documents and Settings\Administrator>ping 1.1.1.1
Pinging 1.1.1.1 with 32 bytes of data:
Reply from 1.1.1.1: bytes=32 time=7ms TTL=126
Reply from 1.1.1.1: bytes=32 time=8ms TTL=126
Reply from 1.1.1.1: bytes=32 time=8ms TTL=126
Ping statistics for 1.1.1.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 7ms, Maximum = 8ms, Average = 7ms
Control-C
^C
tylko musisz miec na Mikrotiku
[admin@MikroTik] /ip/firewall/nat> print
Flags: X - disabled, I - invalid; D - dynamic
0 chain=srcnat action=masquerade out-interface-list=WAN log=no log-prefix=""
ewentualnie
[admin@MikroTik] /ip/firewall/nat> print
Flags: X - disabled, I - invalid; D - dynamic
0 chain=srcnat action=masquerade src-address=10.8.1.0/24
out-interface-list=WAN log=no log-prefix=""
Co do widoczności reszty sieci za tunelem ovpn 192.168.1.120 > 192.168.100.100 na razie nie działa wiec zobaczę wieczorem czy to kwestia routingu na mt czy konfiguracji tunelu albo firewala
Zapomniałem dodać że w wariancie nr2 jeżeli padnie tunel wg to:
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 wg0
nie będzie netu chyba że tak jak pisali jakiś wachdog typu ping co ileś sekund na 2 stronę tunelu np na 10.8.1.1 i jak nie odpowiada to trzeba wywalić trasę 0.0.0.0 przez wg0 i dodać przez lte
route del -net 0.0.0.0/0
route add -net 0.0.0.0/0 gw 100.110.10.1
=========================
Edit 2
Bynajmniej coś nie chcę taka konfiguracja mi działać przy połączeniu
Asus <wg> MT <ovpn> NG
nawet jak dodam wszystkie trasy z palca
root@OWNG:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.11.2 0.0.0.0 UG 0 0 0 eth1
10.8.0.0 0.0.0.0 255.255.255.248 U 0 0 0 tun0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.8.2.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
172.16.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
192.168.55.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.101.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
root@OWNG:~# ping 192.168.55.152
PING 192.168.55.152 (192.168.55.152): 56 data bytes
^C
--- 192.168.55.152 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
root@OWNG:~# ping 192.168.1.120
PING 192.168.1.120 (192.168.1.120): 56 data bytes
^C
--- 192.168.1.120 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
[admin@MikroTik] > ip route/ print
Flags: D - DYNAMIC; A - ACTIVE; c, s, d, v, y - COPY
Columns: DST-ADDRESS, GATEWAY, DISTANCE
# DST-ADDRESS GATEWAY DISTANCE
DAd 0.0.0.0/0 172.16.11.2 1
DAc 10.8.0.0/29 ovpn-out1 0
DAc 10.8.1.0/24 wireguard1 0
DAc 10.8.2.0/24 wireguard2 0
DAc 172.16.11.0/24 ether5 0
0 As 192.168.1.0/24 wireguard1 1
1 As 192.168.55.0/24 wireguard2 1
DAv 192.168.100.0/24 10.8.0.1 1
DAc 192.168.101.0/24 ether6 0
ale za to jak dodałem sobie kolejną podsieć 192.168.55.0/24 i ona łączy się przez osobny tunel wireguard2 przez połączeniówke 10.8.2.0/24
OW_TL
config interface 'wg0'
option proto 'wireguard'
option private_key 'sDpLToaFR35XhcdnGobbD/kMFszvMvc86iB+/xQG/3A='
list addresses '10.8.2.4/24'
config wireguard_wg0
option public_key 'BSz9CeOFs+njFTkEthOtz3r/YUAuLjxPu4sc6PUWrVI='
option route_allowed_ips '1'
list allowed_ips '10.8.1.0/24 10.8.2.0/24 10.8.0.0/29 192.168.100.0/24 192.168.101.0/24 192.168.1.0/24'
option endpoint_host '172.16.11.11'
option endpoint_port '13232'
option persistent_keepalive '25'
option description 'OW_TL'
root@OW_TL:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.11.2 0.0.0.0 UG 0 0 0 eth1
10.8.0.0 0.0.0.0 255.255.255.248 U 0 0 0 wg0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
10.8.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
172.16.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
192.168.55.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
192.168.101.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
do sieci Asusa 192.168.1.0/24 przez Mikrotik
C:\Documents and Settings\Administrator>ping -t 192.168.1.120
Pinging 192.168.1.120 with 32 bytes of data:
Reply from 192.168.1.120: bytes=32 time=3ms TTL=125
Reply from 192.168.1.120: bytes=32 time=2ms TTL=125
Reply from 192.168.1.120: bytes=32 time=2ms TTL=125
Reply from 192.168.1.120: bytes=32 time=2ms TTL=125
Reply from 192.168.1.120: bytes=32 time=2ms TTL=125
Reply from 192.168.1.120: bytes=32 time=2ms TTL=125
Ping statistics for 192.168.1.120:
Packets: Sent = 6, Received = 6, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 3ms, Average = 2ms
Control-C
^C
C:\Documents and Settings\Administrator>tracert 192.168.1.120
Tracing route to 192.168.1.120 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms OW_TL.lan [192.168.55.1]
2 1 ms <1 ms <1 ms 10.8.2.1
3 2 ms 1 ms 1 ms 10.8.1.4
4 2 ms 2 ms 2 ms 192.168.1.120
Trace complete.
i w drugą strone z Asusa
config interface 'wg0'
option proto 'wireguard'
option private_key 'yJA80gcARrR8m5QgTJIspgVIGkgBX8GwAso0emPQB2I='
list addresses '10.8.1.4/24'
config wireguard_wg0
option public_key 'yrIm5LB5Hcs7hVRKXIs86/x3g+LhItwyJCU8+/FStmU='
option route_allowed_ips '1'
list allowed_ips '10.8.1.0/24 10.8.2.0/24 10.8.0.0/29 192.168.100.0/24 192.168.101.0/24 192.168.55.0/2
option endpoint_host '172.16.11.11'
option endpoint_port '13231'
option persistent_keepalive '25'
option description 'OW_Asus'
root@OW_Asus:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 100.110.10.1 0.0.0.0 UG 0 0 0 eth1
10.8.0.0 0.0.0.0 255.255.255.248 U 0 0 0 wg0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
10.8.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
100.110.10.0 0.0.0.0 255.255.255.248 U 0 0 0 eth1
172.16.11.11 100.110.10.1 255.255.255.255 UGH 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.55.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
192.168.101.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
C:\Documents and Settings\Administrator>ping 192.168.55.152
Pinging 192.168.55.152 with 32 bytes of data:
Reply from 192.168.55.152: bytes=32 time=2ms TTL=125
Reply from 192.168.55.152: bytes=32 time=2ms TTL=125
Reply from 192.168.55.152: bytes=32 time=2ms TTL=125
Reply from 192.168.55.152: bytes=32 time=2ms TTL=125
Ping statistics for 192.168.55.152:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
C:\Documents and Settings\Administrator>tracert 192.168.55.152
Tracing route to 192.168.55.152 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms OW_Asus.lan [192.168.1.1]
2 1 ms 1 ms 1 ms 10.8.1.1
3 1 ms 1 ms 1 ms 10.8.2.4
4 2 ms 1 ms 2 ms 192.168.55.152
Trace complete.
Wnioski
1. Konfiguracja przez wireguard działa wersja owrt 22.03 rc6 wersja mikrotika 7.4 Stable
2. Konfiguracja przez wireguard jest dość prosta w przeciwieństwie do ovpn
3. Robi się straszny makaron tych sieci jakie trzeba recznie dodawać w list allowed_ips
4. W MT trzeba dodać ręcznie trasy: jakie sieci wiszą za danym wireguardem
0 As 192.168.1.0/24 wireguard1 1
1 As 192.168.55.0/24 wireguard2 1
na razie tyle