1
1
# Advanced network setup
2
2
3
3
Renting a server in a datacenter usually gets you one IP address. You
4
- should not bridge your local VM traffic together with the physical
5
- Ethernet uplink port. Instead, setup a bridge only for the Virtual
6
- Machines, and provide them with Internet through NAT just like your
7
- plastic ADSL router at home.
8
-
4
+ must not bridge your local VM traffic together with the physical
5
+ Ethernet uplink port. Instead, setup a host-internal bridge for the
6
+ Virtual Machines, and provide them with Internet through NAT just like
7
+ your plastic ADSL router at home.
9
8
10
9
## A bridge to link TAP interfaces
11
10
12
11
Instead of placing MicroVMs directly on a LAN, one can also use a TAP
13
12
interface to get a virtual Ethernet interface on the host. Although it
14
- is possible to assign individual IP configuration to these individual
15
- interfaces, let us avoid the additional configuration effort and
16
- create a bridge instead:
13
+ is possible to [ assign individual IP
14
+ configuration] ( ./routed-network.md ) to these individual interfaces,
15
+ let us avoid the additional configuration effort and create a bridge
16
+ instead:
17
17
18
18
``` nix
19
- systemd.network = {
20
- netdevs."10-microvm".netdevConfig = {
21
- Kind = "bridge";
22
- Name = "microvm";
23
- };
24
- networks."10-microvm" = {
25
- matchConfig.Name = "microvm";
26
- networkConfig = {
27
- DHCPServer = true;
28
- IPv6SendRA = true;
29
- };
30
- addresses = [ {
31
- addressConfig.Address = "10.0.0.1/24";
32
- } {
33
- addressConfig.Address = "fd12:3456:789a::1/64";
34
- } ];
35
- ipv6Prefixes = [ {
36
- ipv6PrefixConfig.Prefix = "fd12:3456:789a::/64";
37
- } ];
19
+ systemd.network.netdevs."10-microvm".netdevConfig = {
20
+ Kind = "bridge";
21
+ Name = "microvm";
22
+ };
23
+ systemd.network.networks."10-microvm" = {
24
+ matchConfig.Name = "microvm";
25
+ networkConfig = {
26
+ DHCPServer = true;
27
+ IPv6SendRA = true;
38
28
};
29
+ addresses = [ {
30
+ addressConfig.Address = "10.0.0.1/24";
31
+ } {
32
+ addressConfig.Address = "fd12:3456:789a::1/64";
33
+ } ];
34
+ ipv6Prefixes = [ {
35
+ ipv6PrefixConfig.Prefix = "fd12:3456:789a::/64";
36
+ } ];
39
37
};
40
38
41
39
# Allow inbound traffic for the DHCP server
@@ -50,12 +48,10 @@ Last, the TAP interfaces of MicroVMs shall be attached to this central
50
48
bridge. Make sure your ` matchConfig ` matches just the interfaces you
51
49
want!
52
50
``` nix
53
- systemd.network = {
54
- networks."11-microvm" = {
55
- matchConfig.Name = "vm-*";
56
- # Attach to the bridge that was configured above
57
- networkConfig.Bridge = "microvm";
58
- };
51
+ systemd.network.networks."11-microvm" = {
52
+ matchConfig.Name = "vm-*";
53
+ # Attach to the bridge that was configured above
54
+ networkConfig.Bridge = "microvm";
59
55
};
60
56
```
61
57
@@ -71,9 +67,13 @@ MicroVMs. NAT works for this address family, too!
71
67
``` nix
72
68
networking.nat = {
73
69
enable = true;
70
+ # NAT66 exists and works. But if you have a proper subnet in
71
+ # 2000::/3 you should route that and remove this setting:
74
72
enableIPv6 = true;
73
+
75
74
# Change this to the interface with upstream Internet access
76
75
externalInterface = "eth0";
76
+ # The bridge where you want to provide Internet access
77
77
internalInterfaces = [ "microvm" ];
78
78
};
79
79
```
0 commit comments