]> git.proxmox.com Git - pve-docs.git/blame - pve-network.adoc
Update Dokumentation to Systemd Network Interface Names
[pve-docs.git] / pve-network.adoc
CommitLineData
80c0adcb 1[[sysadmin_network_configuration]]
0bcd1f7f
DM
2Network Configuration
3---------------------
5f09af76
DM
4ifdef::wiki[]
5:pve-toplevel:
6endif::wiki[]
7
0bcd1f7f
DM
8{pve} uses a bridged networking model. Each host can have up to 4094
9bridges. Bridges are like physical network switches implemented in
10software. All VMs can share a single bridge, as if
11virtual network cables from each guest were all plugged into the same
12switch. But you can also create multiple bridges to separate network
13domains.
14
15For connecting VMs to the outside world, bridges are attached to
16physical network cards. For further flexibility, you can configure
17VLANs (IEEE 802.1q) and network bonding, also known as "link
18aggregation". That way it is possible to build complex and flexible
19virtual networks.
20
8c1189b6
FG
21Debian traditionally uses the `ifup` and `ifdown` commands to
22configure the network. The file `/etc/network/interfaces` contains the
23whole network setup. Please refer to to manual page (`man interfaces`)
0bcd1f7f
DM
24for a complete format description.
25
26NOTE: {pve} does not write changes directly to
8c1189b6
FG
27`/etc/network/interfaces`. Instead, we write into a temporary file
28called `/etc/network/interfaces.new`, and commit those changes when
0bcd1f7f
DM
29you reboot the node.
30
31It is worth mentioning that you can directly edit the configuration
32file. All {pve} tools tries hard to keep such direct user
33modifications. Using the GUI is still preferable, because it
34protect you from errors.
35
5eba0743 36
0bcd1f7f
DM
37Naming Conventions
38~~~~~~~~~~~~~~~~~~
39
40We currently use the following naming conventions for device names:
41
7a0d4784
WL
42* New Ethernet devices: en*, systemd network interface names.
43
44* Lagacy Ethernet devices: eth[N], where 0 ≤ N (`eth0`, `eth1`, ...)
45They are available when Proxmox VE has been updated by an earlier version.
0bcd1f7f
DM
46
47* Bridge names: vmbr[N], where 0 ≤ N ≤ 4094 (`vmbr0` - `vmbr4094`)
48
49* Bonds: bond[N], where 0 ≤ N (`bond0`, `bond1`, ...)
50
51* VLANs: Simply add the VLAN number to the device name,
7a0d4784 52 separated by a period (`eno1.50`, `bond1.30`)
0bcd1f7f
DM
53
54This makes it easier to debug networks problems, because the device
55names implies the device type.
56
7a0d4784
WL
57Systemd Network Interface Names
58^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59
60Two character prefixes based on the type of interface:
61
62* en — Enoernet
63
64* sl — serial line IP (slip)
65
66* wl — wlan
67
68* ww — wwan
69
70The next characters depence on the device driver and the fact which schema matches first.
71
72* o<index>[n<phys_port_name>|d<dev_port>] — devices on board
73
74* s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — device by hotplug id
75
76* [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — devices by bus id
77
78* x<MAC> — device by MAC address
79
80The most common patterns are
81
82* eno1 — is the first on board NIC
83
84* enp3s0f1 — is the NIC on pcibus 3 slot 0 and use the NIC function 1.
85
86For more information see link:https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L20[Systemd Network Interface Names]
87
0bcd1f7f
DM
88Default Configuration using a Bridge
89~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90
91The installation program creates a single bridge named `vmbr0`, which
7a0d4784 92is connected to the first ethernet card `eno0`. The corresponding
8c1189b6 93configuration in `/etc/network/interfaces` looks like this:
0bcd1f7f
DM
94
95----
96auto lo
97iface lo inet loopback
98
7a0d4784 99iface eno1 inet manual
0bcd1f7f
DM
100
101auto vmbr0
102iface vmbr0 inet static
103 address 192.168.10.2
104 netmask 255.255.255.0
105 gateway 192.168.10.1
7a0d4784 106 bridge_ports eno1
0bcd1f7f
DM
107 bridge_stp off
108 bridge_fd 0
109----
110
111Virtual machines behave as if they were directly connected to the
112physical network. The network, in turn, sees each virtual machine as
113having its own MAC, even though there is only one network cable
114connecting all of these VMs to the network.
115
116
117Routed Configuration
118~~~~~~~~~~~~~~~~~~~~
119
120Most hosting providers do not support the above setup. For security
121reasons, they disable networking as soon as they detect multiple MAC
122addresses on a single interface.
123
124TIP: Some providers allows you to register additional MACs on there
125management interface. This avoids the problem, but is clumsy to
126configure because you need to register a MAC for each of your VMs.
127
8c1189b6 128You can avoid the problem by ``routing'' all traffic via a single
0bcd1f7f
DM
129interface. This makes sure that all network packets use the same MAC
130address.
131
8c1189b6 132A common scenario is that you have a public IP (assume `192.168.10.2`
0bcd1f7f 133for this example), and an additional IP block for your VMs
8c1189b6 134(`10.10.10.1/255.255.255.0`). We recommend the following setup for such
0bcd1f7f
DM
135situations:
136
137----
138auto lo
139iface lo inet loopback
140
7a0d4784
WL
141auto eno1
142iface eno1 inet static
0bcd1f7f
DM
143 address 192.168.10.2
144 netmask 255.255.255.0
145 gateway 192.168.10.1
7a0d4784 146 post-up echo 1 > /proc/sys/net/ipv4/conf/eno1/proxy_arp
0bcd1f7f
DM
147
148
149auto vmbr0
150iface vmbr0 inet static
151 address 10.10.10.1
152 netmask 255.255.255.0
153 bridge_ports none
154 bridge_stp off
155 bridge_fd 0
156----
157
158
8c1189b6
FG
159Masquerading (NAT) with `iptables`
160~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0bcd1f7f
DM
161
162In some cases you may want to use private IPs behind your Proxmox
163host's true IP, and masquerade the traffic using NAT:
164
165----
166auto lo
167iface lo inet loopback
168
7a0d4784 169auto eno0
0bcd1f7f 170#real IP adress
7a0d4784 171iface eno1 inet static
0bcd1f7f
DM
172 address 192.168.10.2
173 netmask 255.255.255.0
174 gateway 192.168.10.1
175
176auto vmbr0
177#private sub network
178iface vmbr0 inet static
179 address 10.10.10.1
180 netmask 255.255.255.0
181 bridge_ports none
182 bridge_stp off
183 bridge_fd 0
184
185 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784
WL
186 post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
187 post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
0bcd1f7f
DM
188----
189
b4c06a93
WL
190
191Linux Bond
192~~~~~~~~~~
193
3eafe338
WL
194Bonding (also called NIC teaming or Link Aggregation) is a technique
195for binding multiple NIC's to a single network device. It is possible
196to achieve different goals, like make the network fault-tolerant,
197increase the performance or both together.
198
199High-speed hardware like Fibre Channel and the associated switching
200hardware can be quite expensive. By doing link aggregation, two NICs
201can appear as one logical interface, resulting in double speed. This
202is a native Linux kernel feature that is supported by most
203switches. If your nodes have multiple Ethernet ports, you can
204distribute your points of failure by running network cables to
205different switches and the bonded connection will failover to one
206cable or the other in case of network trouble.
207
208Aggregated links can improve live-migration delays and improve the
209speed of replication of data between Proxmox VE Cluster nodes.
b4c06a93
WL
210
211There are 7 modes for bonding:
212
213* *Round-robin (balance-rr):* Transmit network packets in sequential
214order from the first available network interface (NIC) slave through
215the last. This mode provides load balancing and fault tolerance.
216
217* *Active-backup (active-backup):* Only one NIC slave in the bond is
218active. A different slave becomes active if, and only if, the active
219slave fails. The single logical bonded interface's MAC address is
220externally visible on only one NIC (port) to avoid distortion in the
221network switch. This mode provides fault tolerance.
222
223* *XOR (balance-xor):* Transmit network packets based on [(source MAC
224address XOR'd with destination MAC address) modulo NIC slave
225count]. This selects the same NIC slave for each destination MAC
226address. This mode provides load balancing and fault tolerance.
227
228* *Broadcast (broadcast):* Transmit network packets on all slave
229network interfaces. This mode provides fault tolerance.
230
231* *IEEE 802.3ad Dynamic link aggregation (802.3ad)(LACP):* Creates
232aggregation groups that share the same speed and duplex
233settings. Utilizes all slave network interfaces in the active
234aggregator group according to the 802.3ad specification.
235
236* *Adaptive transmit load balancing (balance-tlb):* Linux bonding
237driver mode that does not require any special network-switch
238support. The outgoing network packet traffic is distributed according
239to the current load (computed relative to the speed) on each network
240interface slave. Incoming traffic is received by one currently
241designated slave network interface. If this receiving slave fails,
242another slave takes over the MAC address of the failed receiving
243slave.
244
e60ce90c 245* *Adaptive load balancing (balance-alb):* Includes balance-tlb plus receive
b4c06a93
WL
246load balancing (rlb) for IPV4 traffic, and does not require any
247special network switch support. The receive load balancing is achieved
248by ARP negotiation. The bonding driver intercepts the ARP Replies sent
249by the local system on their way out and overwrites the source
250hardware address with the unique hardware address of one of the NIC
251slaves in the single logical bonded interface such that different
252network-peers use different MAC addresses for their network packet
253traffic.
254
255For the most setups the active-backup are the best choice or if your
256switch support LACP "IEEE 802.3ad" this mode should be preferred.
257
cd1de2c2
WL
258The following bond configuration can be used as distributed/shared
259storage network. The benefit would be that you get more speed and the
260network will be fault-tolerant.
261
b4c06a93
WL
262.Example: Use bond with fixed IP address
263----
264auto lo
265iface lo inet loopback
266
7a0d4784 267iface eno1 inet manual
b4c06a93 268
7a0d4784 269iface eno2 inet manual
b4c06a93
WL
270
271auto bond0
272iface bond0 inet static
7a0d4784 273 slaves eno1 eno2
b4c06a93
WL
274 address 192.168.1.2
275 netmask 255.255.255.0
276 bond_miimon 100
277 bond_mode 802.3ad
278 bond_xmit_hash_policy layer2+3
279
280auto vmbr0
281iface vmbr0 inet static
282 address 10.10.10.2
283 netmask 255.255.255.0
284 gateway 10.10.10.1
7a0d4784 285 bridge_ports eno1
b4c06a93
WL
286 bridge_stp off
287 bridge_fd 0
288
289----
290
cd1de2c2
WL
291
292Another possibility it to use the bond directly as bridge port.
293This can be used to make the guest network fault-tolerant.
294
295.Example: Use a bond as bridge port
b4c06a93
WL
296----
297auto lo
298iface lo inet loopback
299
7a0d4784 300iface eno1 inet manual
b4c06a93 301
7a0d4784 302iface eno2 inet manual
b4c06a93
WL
303
304auto bond0
305iface bond0 inet maunal
7a0d4784 306 slaves eno1 eno2
b4c06a93
WL
307 bond_miimon 100
308 bond_mode 802.3ad
309 bond_xmit_hash_policy layer2+3
310
311auto vmbr0
312iface vmbr0 inet static
313 address 10.10.10.2
314 netmask 255.255.255.0
315 gateway 10.10.10.1
316 bridge_ports bond0
317 bridge_stp off
318 bridge_fd 0
319
320----
321
0bcd1f7f
DM
322////
323TODO: explain IPv6 support?
324TODO: explan OVS
325////