1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

test-network: add tests for creating routes to wireguard's AllowedIPs=

This commit is contained in:
Yu Watanabe 2021-11-29 16:49:24 +09:00
parent e908434458
commit 6387cac3f3
4 changed files with 64 additions and 92 deletions

View File

@ -11,6 +11,8 @@ ListenPort=4500
# The key below should be overridden by PrivateKeyFile=
PrivateKey=EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong=
PrivateKeyFile=/run/systemd/network/25-wireguard-private-key.txt
RouteTable=1234
RouteMetric=123
# peer 1
[WireGuardPeer]

View File

@ -6,95 +6,3 @@ Name=wg98
Address=192.168.123.123/24
Address=fd8d:4d6d:3ccb:0500::1/64
IPv6AcceptRA=no
# nat64 via 1
[Route]
Destination = fd8d:4d6d:3ccb:0c79:2339:edce::/96
# nat64 via 2
[Route]
Destination = fd8d:4d6d:3ccb:a072:80da:de4f::/96
# nat64 via 3
[Route]
Destination = fd8d:4d6d:3ccb:f349:c4f0:10c1::/96
# nat64 via 4
[Route]
Destination = fd8d:4d6d:3ccb:b684:4f81:2e3e::/96
# nat64 via 5
[Route]
Destination = fd8d:4d6d:3ccb:c624:6bf7:4c09::/96
# nat64 via 6
[Route]
Destination = fd8d:4d6d:3ccb:9c11:d820:2e96::/96
# nat64 via 7
[Route]
Destination = fd8d:4d6d:3ccb:bad5:495d:8e9c::/96
# nat64 via 8
[Route]
Destination = fd8d:4d6d:3ccb:1e54:1415:35d0::/96
# nat64 via 9
[Route]
Destination = fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96
# nat64 via 10
[Route]
Destination = fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96
# nat64 via 11
[Route]
Destination = fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96
# nat64 via 12
[Route]
Destination = fd8d:4d6d:3ccb:d4f9:05dc:9296::/96
# nat64 via 13
[Route]
Destination = fd8d:4d6d:3ccb:b39c:9cdc:755a::/96
# nat64 via 14
[Route]
Destination = fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96
# nat64 via 15
[Route]
Destination = fd8d:4d6d:3ccb:900c:d437:ec27::/96
# nat64 via 16
[Route]
Destination = fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96
# nat64 via 17
[Route]
Destination = fd8d:4d6d:3ccb:e2e1:ae15:103f::/96
# nat64 via 18
[Route]
Destination = fd8d:4d6d:3ccb:5660:679d:3532::/96
# nat64 via 19
[Route]
Destination = fd8d:4d6d:3ccb:6825:573f:30f3::/96
# nat64 via 20
[Route]
Destination = fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96
# nat64 via 21
[Route]
Destination = fd8d:4d6d:3ccb:8d4d:0bab:7280::/96
# nat64 via 22
[Route]
Destination = fd8d:4d6d:3ccb:a3f3:df38:19b0::/96
# nat64 via 23
[Route]
Destination = fd8d:4d6d:3ccb:9742:9931:5217::/96

View File

@ -6,6 +6,9 @@ Kind=wireguard
[WireGuard]
ListenPort=51820
FwMark=1234
# settings below are ignored.
RouteTable=off
RouteMetric=456
[WireGuardPeer]
PublicKey=RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=
@ -14,3 +17,5 @@ AllowedIPs=fd31:bf08:57cb::/48,192.168.26.0/24
Endpoint=192.168.27.3:51820
PresharedKey=IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M=
PersistentKeepalive=20
RouteTable=1234
RouteMetric=123

View File

@ -1383,6 +1383,63 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
print(output)
self.assertIn('inet6 fd8d:4d6d:3ccb:500::1/64 scope global', output)
output = check_output('ip -4 route show dev wg99 table 1234')
print(output)
self.assertIn('192.168.26.0/24 proto static metric 123', output)
output = check_output('ip -6 route show dev wg99 table 1234')
print(output)
self.assertIn('fd31:bf08:57cb::/48 proto static metric 123 pref medium', output)
output = check_output('ip -6 route show dev wg98 table 1234')
print(output)
self.assertIn('fd8d:4d6d:3ccb:500:c79:2339:edce:ece1 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:1dbf:ca8a:32d3:dd81 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:1e54:1415:35d0:a47c proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:270d:b5dd:4a3f:8909 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:5660:679d:3532:94d8 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:6825:573f:30f3:9472 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:6f2e:6888:c6fd:dfb9 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:8d4d:bab:7280:a09a proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:900c:d437:ec27:8822 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:9742:9931:5217:18d5 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:9c11:d820:2e96:9be0 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:a072:80da:de4f:add1 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:a3f3:df38:19b0:721 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:a94b:cd6a:a32d:90e6 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:b39c:9cdc:755a:ead3 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:b684:4f81:2e3e:132e proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:bad5:495d:8e9c:3427 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:bfe5:c3c3:5d77:fcb proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:c624:6bf7:4c09:3b59 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:d4f9:5dc:9296:a1a proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:dcdd:d33b:90c9:6088 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:e2e1:ae15:103f:f376 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:500:f349:c4f0:10c1:6b4 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:c79:2339:edce::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:1e54:1415:35d0::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:5660:679d:3532::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:6825:573f:30f3::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:8d4d:bab:7280::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:900c:d437:ec27::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:9742:9931:5217::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:9c11:d820:2e96::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:a072:80da:de4f::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:a3f3:df38:19b0::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:b39c:9cdc:755a::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:b684:4f81:2e3e::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:bad5:495d:8e9c::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:c624:6bf7:4c09::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:d4f9:5dc:9296::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:e2e1:ae15:103f::/96 proto static metric 123 pref medium', output)
self.assertIn('fd8d:4d6d:3ccb:f349:c4f0:10c1::/96 proto static metric 123 pref medium', output)
if shutil.which('wg'):
call('wg')