Skip to content

Commit 6387cac

Browse files
committed
test-network: add tests for creating routes to wireguard's AllowedIPs=
1 parent e908434 commit 6387cac

File tree

4 files changed

+64
-92
lines changed

4 files changed

+64
-92
lines changed

test/test-network/conf/25-wireguard-23-peers.netdev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ListenPort=4500
1111
# The key below should be overridden by PrivateKeyFile=
1212
PrivateKey=EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong=
1313
PrivateKeyFile=/run/systemd/network/25-wireguard-private-key.txt
14+
RouteTable=1234
15+
RouteMetric=123
1416

1517
# peer 1
1618
[WireGuardPeer]

test/test-network/conf/25-wireguard-23-peers.network

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,95 +6,3 @@ Name=wg98
66
Address=192.168.123.123/24
77
Address=fd8d:4d6d:3ccb:0500::1/64
88
IPv6AcceptRA=no
9-
10-
# nat64 via 1
11-
[Route]
12-
Destination = fd8d:4d6d:3ccb:0c79:2339:edce::/96
13-
14-
# nat64 via 2
15-
[Route]
16-
Destination = fd8d:4d6d:3ccb:a072:80da:de4f::/96
17-
18-
# nat64 via 3
19-
[Route]
20-
Destination = fd8d:4d6d:3ccb:f349:c4f0:10c1::/96
21-
22-
# nat64 via 4
23-
[Route]
24-
Destination = fd8d:4d6d:3ccb:b684:4f81:2e3e::/96
25-
26-
# nat64 via 5
27-
[Route]
28-
Destination = fd8d:4d6d:3ccb:c624:6bf7:4c09::/96
29-
30-
# nat64 via 6
31-
[Route]
32-
Destination = fd8d:4d6d:3ccb:9c11:d820:2e96::/96
33-
34-
# nat64 via 7
35-
[Route]
36-
Destination = fd8d:4d6d:3ccb:bad5:495d:8e9c::/96
37-
38-
# nat64 via 8
39-
[Route]
40-
Destination = fd8d:4d6d:3ccb:1e54:1415:35d0::/96
41-
42-
# nat64 via 9
43-
[Route]
44-
Destination = fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96
45-
46-
# nat64 via 10
47-
[Route]
48-
Destination = fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96
49-
50-
# nat64 via 11
51-
[Route]
52-
Destination = fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96
53-
54-
# nat64 via 12
55-
[Route]
56-
Destination = fd8d:4d6d:3ccb:d4f9:05dc:9296::/96
57-
58-
# nat64 via 13
59-
[Route]
60-
Destination = fd8d:4d6d:3ccb:b39c:9cdc:755a::/96
61-
62-
# nat64 via 14
63-
[Route]
64-
Destination = fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96
65-
66-
# nat64 via 15
67-
[Route]
68-
Destination = fd8d:4d6d:3ccb:900c:d437:ec27::/96
69-
70-
# nat64 via 16
71-
[Route]
72-
Destination = fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96
73-
74-
# nat64 via 17
75-
[Route]
76-
Destination = fd8d:4d6d:3ccb:e2e1:ae15:103f::/96
77-
78-
# nat64 via 18
79-
[Route]
80-
Destination = fd8d:4d6d:3ccb:5660:679d:3532::/96
81-
82-
# nat64 via 19
83-
[Route]
84-
Destination = fd8d:4d6d:3ccb:6825:573f:30f3::/96
85-
86-
# nat64 via 20
87-
[Route]
88-
Destination = fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96
89-
90-
# nat64 via 21
91-
[Route]
92-
Destination = fd8d:4d6d:3ccb:8d4d:0bab:7280::/96
93-
94-
# nat64 via 22
95-
[Route]
96-
Destination = fd8d:4d6d:3ccb:a3f3:df38:19b0::/96
97-
98-
# nat64 via 23
99-
[Route]
100-
Destination = fd8d:4d6d:3ccb:9742:9931:5217::/96

test/test-network/conf/25-wireguard.netdev

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Kind=wireguard
66
[WireGuard]
77
ListenPort=51820
88
FwMark=1234
9+
# settings below are ignored.
10+
RouteTable=off
11+
RouteMetric=456
912

1013
[WireGuardPeer]
1114
PublicKey=RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=
@@ -14,3 +17,5 @@ AllowedIPs=fd31:bf08:57cb::/48,192.168.26.0/24
1417
Endpoint=192.168.27.3:51820
1518
PresharedKey=IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M=
1619
PersistentKeepalive=20
20+
RouteTable=1234
21+
RouteMetric=123

test/test-network/systemd-networkd-tests.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,63 @@ def test_wireguard(self):
13831383
print(output)
13841384
self.assertIn('inet6 fd8d:4d6d:3ccb:500::1/64 scope global', output)
13851385

1386+
output = check_output('ip -4 route show dev wg99 table 1234')
1387+
print(output)
1388+
self.assertIn('192.168.26.0/24 proto static metric 123', output)
1389+
1390+
output = check_output('ip -6 route show dev wg99 table 1234')
1391+
print(output)
1392+
self.assertIn('fd31:bf08:57cb::/48 proto static metric 123 pref medium', output)
1393+
1394+
output = check_output('ip -6 route show dev wg98 table 1234')
1395+
print(output)
1396+
self.assertIn('fd8d:4d6d:3ccb:500:c79:2339:edce:ece1 proto static metric 123 pref medium', output)
1397+
self.assertIn('fd8d:4d6d:3ccb:500:1dbf:ca8a:32d3:dd81 proto static metric 123 pref medium', output)
1398+
self.assertIn('fd8d:4d6d:3ccb:500:1e54:1415:35d0:a47c proto static metric 123 pref medium', output)
1399+
self.assertIn('fd8d:4d6d:3ccb:500:270d:b5dd:4a3f:8909 proto static metric 123 pref medium', output)
1400+
self.assertIn('fd8d:4d6d:3ccb:500:5660:679d:3532:94d8 proto static metric 123 pref medium', output)
1401+
self.assertIn('fd8d:4d6d:3ccb:500:6825:573f:30f3:9472 proto static metric 123 pref medium', output)
1402+
self.assertIn('fd8d:4d6d:3ccb:500:6f2e:6888:c6fd:dfb9 proto static metric 123 pref medium', output)
1403+
self.assertIn('fd8d:4d6d:3ccb:500:8d4d:bab:7280:a09a proto static metric 123 pref medium', output)
1404+
self.assertIn('fd8d:4d6d:3ccb:500:900c:d437:ec27:8822 proto static metric 123 pref medium', output)
1405+
self.assertIn('fd8d:4d6d:3ccb:500:9742:9931:5217:18d5 proto static metric 123 pref medium', output)
1406+
self.assertIn('fd8d:4d6d:3ccb:500:9c11:d820:2e96:9be0 proto static metric 123 pref medium', output)
1407+
self.assertIn('fd8d:4d6d:3ccb:500:a072:80da:de4f:add1 proto static metric 123 pref medium', output)
1408+
self.assertIn('fd8d:4d6d:3ccb:500:a3f3:df38:19b0:721 proto static metric 123 pref medium', output)
1409+
self.assertIn('fd8d:4d6d:3ccb:500:a94b:cd6a:a32d:90e6 proto static metric 123 pref medium', output)
1410+
self.assertIn('fd8d:4d6d:3ccb:500:b39c:9cdc:755a:ead3 proto static metric 123 pref medium', output)
1411+
self.assertIn('fd8d:4d6d:3ccb:500:b684:4f81:2e3e:132e proto static metric 123 pref medium', output)
1412+
self.assertIn('fd8d:4d6d:3ccb:500:bad5:495d:8e9c:3427 proto static metric 123 pref medium', output)
1413+
self.assertIn('fd8d:4d6d:3ccb:500:bfe5:c3c3:5d77:fcb proto static metric 123 pref medium', output)
1414+
self.assertIn('fd8d:4d6d:3ccb:500:c624:6bf7:4c09:3b59 proto static metric 123 pref medium', output)
1415+
self.assertIn('fd8d:4d6d:3ccb:500:d4f9:5dc:9296:a1a proto static metric 123 pref medium', output)
1416+
self.assertIn('fd8d:4d6d:3ccb:500:dcdd:d33b:90c9:6088 proto static metric 123 pref medium', output)
1417+
self.assertIn('fd8d:4d6d:3ccb:500:e2e1:ae15:103f:f376 proto static metric 123 pref medium', output)
1418+
self.assertIn('fd8d:4d6d:3ccb:500:f349:c4f0:10c1:6b4 proto static metric 123 pref medium', output)
1419+
self.assertIn('fd8d:4d6d:3ccb:c79:2339:edce::/96 proto static metric 123 pref medium', output)
1420+
self.assertIn('fd8d:4d6d:3ccb:1dbf:ca8a:32d3::/96 proto static metric 123 pref medium', output)
1421+
self.assertIn('fd8d:4d6d:3ccb:1e54:1415:35d0::/96 proto static metric 123 pref medium', output)
1422+
self.assertIn('fd8d:4d6d:3ccb:270d:b5dd:4a3f::/96 proto static metric 123 pref medium', output)
1423+
self.assertIn('fd8d:4d6d:3ccb:5660:679d:3532::/96 proto static metric 123 pref medium', output)
1424+
self.assertIn('fd8d:4d6d:3ccb:6825:573f:30f3::/96 proto static metric 123 pref medium', output)
1425+
self.assertIn('fd8d:4d6d:3ccb:6f2e:6888:c6fd::/96 proto static metric 123 pref medium', output)
1426+
self.assertIn('fd8d:4d6d:3ccb:8d4d:bab:7280::/96 proto static metric 123 pref medium', output)
1427+
self.assertIn('fd8d:4d6d:3ccb:900c:d437:ec27::/96 proto static metric 123 pref medium', output)
1428+
self.assertIn('fd8d:4d6d:3ccb:9742:9931:5217::/96 proto static metric 123 pref medium', output)
1429+
self.assertIn('fd8d:4d6d:3ccb:9c11:d820:2e96::/96 proto static metric 123 pref medium', output)
1430+
self.assertIn('fd8d:4d6d:3ccb:a072:80da:de4f::/96 proto static metric 123 pref medium', output)
1431+
self.assertIn('fd8d:4d6d:3ccb:a3f3:df38:19b0::/96 proto static metric 123 pref medium', output)
1432+
self.assertIn('fd8d:4d6d:3ccb:a94b:cd6a:a32d::/96 proto static metric 123 pref medium', output)
1433+
self.assertIn('fd8d:4d6d:3ccb:b39c:9cdc:755a::/96 proto static metric 123 pref medium', output)
1434+
self.assertIn('fd8d:4d6d:3ccb:b684:4f81:2e3e::/96 proto static metric 123 pref medium', output)
1435+
self.assertIn('fd8d:4d6d:3ccb:bad5:495d:8e9c::/96 proto static metric 123 pref medium', output)
1436+
self.assertIn('fd8d:4d6d:3ccb:bfe5:c3c3:5d77::/96 proto static metric 123 pref medium', output)
1437+
self.assertIn('fd8d:4d6d:3ccb:c624:6bf7:4c09::/96 proto static metric 123 pref medium', output)
1438+
self.assertIn('fd8d:4d6d:3ccb:d4f9:5dc:9296::/96 proto static metric 123 pref medium', output)
1439+
self.assertIn('fd8d:4d6d:3ccb:dcdd:d33b:90c9::/96 proto static metric 123 pref medium', output)
1440+
self.assertIn('fd8d:4d6d:3ccb:e2e1:ae15:103f::/96 proto static metric 123 pref medium', output)
1441+
self.assertIn('fd8d:4d6d:3ccb:f349:c4f0:10c1::/96 proto static metric 123 pref medium', output)
1442+
13861443
if shutil.which('wg'):
13871444
call('wg')
13881445

0 commit comments

Comments
 (0)