]> git.proxmox.com Git - pve-docs.git/blame - pve-network.adoc
pve-network.adoc: vlan - s/Nic/NIC/
[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
05213009
EK
8Network configuration can be done either via the GUI, or by manually
9editing the file `/etc/network/interfaces`, which contains the
10whole network configuration. The `interfaces(5)` manual page contains the
11complete format description. All {pve} tools try hard to keep direct
12 user modifications, but using the GUI is still preferable, because it
13protects you from errors.
0bcd1f7f 14
05213009
EK
15Once the network is configured, you can use the Debian traditional tools `ifup`
16and `ifdown` commands to bring interfaces up and down.
0bcd1f7f
DM
17
18NOTE: {pve} does not write changes directly to
8c1189b6
FG
19`/etc/network/interfaces`. Instead, we write into a temporary file
20called `/etc/network/interfaces.new`, and commit those changes when
0bcd1f7f
DM
21you reboot the node.
22
0bcd1f7f
DM
23Naming Conventions
24~~~~~~~~~~~~~~~~~~
25
26We currently use the following naming conventions for device names:
27
05213009
EK
28* Ethernet devices: en*, systemd network interface names. This naming scheme is
29 used for new {pve} installations since version 5.0.
7a0d4784 30
05213009
EK
31* Ethernet devices: eth[N], where 0 ≤ N (`eth0`, `eth1`, ...) This naming
32scheme is used for {pve} hosts which were installed before the 5.0
33release. When upgrading to 5.0, the names are kept as-is.
0bcd1f7f
DM
34
35* Bridge names: vmbr[N], where 0 ≤ N ≤ 4094 (`vmbr0` - `vmbr4094`)
36
37* Bonds: bond[N], where 0 ≤ N (`bond0`, `bond1`, ...)
38
39* VLANs: Simply add the VLAN number to the device name,
7a0d4784 40 separated by a period (`eno1.50`, `bond1.30`)
0bcd1f7f
DM
41
42This makes it easier to debug networks problems, because the device
05213009 43name implies the device type.
cc3cb912 44
7a0d4784
WL
45Systemd Network Interface Names
46^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
8116dea5
DM
48Systemd uses the two character prefix 'en' for Ethernet network
49devices. The next characters depends on the device driver and the fact
cc3cb912 50which schema matches first.
7a0d4784
WL
51
52* o<index>[n<phys_port_name>|d<dev_port>] — devices on board
53
54* s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — device by hotplug id
55
56* [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — devices by bus id
57
58* x<MAC> — device by MAC address
59
cc3cb912 60The most common patterns are:
7a0d4784
WL
61
62* eno1 — is the first on board NIC
63
64* enp3s0f1 — is the NIC on pcibus 3 slot 0 and use the NIC function 1.
65
cc3cb912
DM
66For more information see https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/[Predictable Network Interface Names].
67
05213009
EK
68Choosing a network configuration
69~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70
71Depending on your current network organization and your resources you can
72choose either a bridged, routed, or masquerading networking setup.
73
74{pve} server in a private LAN, using an external gateway to reach the internet
75^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
77The *Bridged* model makes the most sense in this case, and this is also
78the default mode on new {pve} installations.
79Each of your Guest system will have a virtual interface attached to the
80{pve} bridge. This is similar in effect to having the Guest network card
81directly connected to a new switch on your LAN, the {pve} host playing the role
82of the switch.
83
84{pve} server at hosting provider, with public IP ranges for Guests
85^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
87For this setup, you can use either a *Bridged* or *Routed* model, depending on
88what your provider allows.
89
90{pve} server at hosting provider, with a single public IP address
91^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92
93In that case the only way to get outgoing network accesses for your guest
94systems is to use *Masquerading*. For incoming network access to your guests,
95you will need to configure *Port Forwarding*.
96
97For further flexibility, you can configure
98VLANs (IEEE 802.1q) and network bonding, also known as "link
99aggregation". That way it is possible to build complex and flexible
100virtual networks.
7a0d4784 101
0bcd1f7f
DM
102Default Configuration using a Bridge
103~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
05213009
EK
105Bridges are like physical network switches implemented in software.
106All VMs can share a single bridge, or you can create multiple bridges to
107separate network domains. Each host can have up to 4094 bridges.
108
0bcd1f7f 109The installation program creates a single bridge named `vmbr0`, which
04e8476d
EK
110is connected to the first Ethernet card. The corresponding
111configuration in `/etc/network/interfaces` might look like this:
0bcd1f7f
DM
112
113----
114auto lo
115iface lo inet loopback
116
7a0d4784 117iface eno1 inet manual
0bcd1f7f
DM
118
119auto vmbr0
120iface vmbr0 inet static
121 address 192.168.10.2
122 netmask 255.255.255.0
123 gateway 192.168.10.1
7a0d4784 124 bridge_ports eno1
0bcd1f7f
DM
125 bridge_stp off
126 bridge_fd 0
127----
128
129Virtual machines behave as if they were directly connected to the
130physical network. The network, in turn, sees each virtual machine as
131having its own MAC, even though there is only one network cable
132connecting all of these VMs to the network.
133
0bcd1f7f
DM
134Routed Configuration
135~~~~~~~~~~~~~~~~~~~~
136
137Most hosting providers do not support the above setup. For security
138reasons, they disable networking as soon as they detect multiple MAC
139addresses on a single interface.
140
141TIP: Some providers allows you to register additional MACs on there
142management interface. This avoids the problem, but is clumsy to
143configure because you need to register a MAC for each of your VMs.
144
8c1189b6 145You can avoid the problem by ``routing'' all traffic via a single
0bcd1f7f
DM
146interface. This makes sure that all network packets use the same MAC
147address.
148
05213009 149A common scenario is that you have a public IP (assume `198.51.100.5`
0bcd1f7f 150for this example), and an additional IP block for your VMs
05213009 151(`203.0.113.16/29`). We recommend the following setup for such
0bcd1f7f
DM
152situations:
153
154----
155auto lo
156iface lo inet loopback
157
7a0d4784
WL
158auto eno1
159iface eno1 inet static
05213009 160 address 198.51.100.5
0bcd1f7f 161 netmask 255.255.255.0
05213009 162 gateway 198.51.100.1
1ed90852 163 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784 164 post-up echo 1 > /proc/sys/net/ipv4/conf/eno1/proxy_arp
0bcd1f7f
DM
165
166
167auto vmbr0
168iface vmbr0 inet static
05213009
EK
169 address 203.0.113.17
170 netmask 255.255.255.248
0bcd1f7f
DM
171 bridge_ports none
172 bridge_stp off
173 bridge_fd 0
174----
175
176
8c1189b6
FG
177Masquerading (NAT) with `iptables`
178~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0bcd1f7f 179
05213009
EK
180Masquerading allows guests having only a private IP address to access the
181network by using the host IP address for outgoing traffic. Each outgoing
182packet is rewritten by `iptables` to appear as originating from the host,
183and responses are rewritten accordingly to be routed to the original sender.
0bcd1f7f
DM
184
185----
186auto lo
187iface lo inet loopback
188
05213009 189auto eno1
470d4313 190#real IP address
7a0d4784 191iface eno1 inet static
05213009 192 address 198.51.100.5
0bcd1f7f 193 netmask 255.255.255.0
05213009 194 gateway 198.51.100.1
0bcd1f7f
DM
195
196auto vmbr0
197#private sub network
198iface vmbr0 inet static
199 address 10.10.10.1
200 netmask 255.255.255.0
201 bridge_ports none
202 bridge_stp off
203 bridge_fd 0
204
205 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784
WL
206 post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
207 post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
0bcd1f7f
DM
208----
209
b4c06a93
WL
210
211Linux Bond
212~~~~~~~~~~
213
3eafe338
WL
214Bonding (also called NIC teaming or Link Aggregation) is a technique
215for binding multiple NIC's to a single network device. It is possible
216to achieve different goals, like make the network fault-tolerant,
217increase the performance or both together.
218
219High-speed hardware like Fibre Channel and the associated switching
220hardware can be quite expensive. By doing link aggregation, two NICs
221can appear as one logical interface, resulting in double speed. This
222is a native Linux kernel feature that is supported by most
223switches. If your nodes have multiple Ethernet ports, you can
224distribute your points of failure by running network cables to
225different switches and the bonded connection will failover to one
226cable or the other in case of network trouble.
227
228Aggregated links can improve live-migration delays and improve the
229speed of replication of data between Proxmox VE Cluster nodes.
b4c06a93
WL
230
231There are 7 modes for bonding:
232
233* *Round-robin (balance-rr):* Transmit network packets in sequential
234order from the first available network interface (NIC) slave through
235the last. This mode provides load balancing and fault tolerance.
236
237* *Active-backup (active-backup):* Only one NIC slave in the bond is
238active. A different slave becomes active if, and only if, the active
239slave fails. The single logical bonded interface's MAC address is
240externally visible on only one NIC (port) to avoid distortion in the
241network switch. This mode provides fault tolerance.
242
243* *XOR (balance-xor):* Transmit network packets based on [(source MAC
244address XOR'd with destination MAC address) modulo NIC slave
245count]. This selects the same NIC slave for each destination MAC
246address. This mode provides load balancing and fault tolerance.
247
248* *Broadcast (broadcast):* Transmit network packets on all slave
249network interfaces. This mode provides fault tolerance.
250
251* *IEEE 802.3ad Dynamic link aggregation (802.3ad)(LACP):* Creates
252aggregation groups that share the same speed and duplex
253settings. Utilizes all slave network interfaces in the active
254aggregator group according to the 802.3ad specification.
255
256* *Adaptive transmit load balancing (balance-tlb):* Linux bonding
257driver mode that does not require any special network-switch
258support. The outgoing network packet traffic is distributed according
259to the current load (computed relative to the speed) on each network
260interface slave. Incoming traffic is received by one currently
261designated slave network interface. If this receiving slave fails,
262another slave takes over the MAC address of the failed receiving
263slave.
264
e60ce90c 265* *Adaptive load balancing (balance-alb):* Includes balance-tlb plus receive
b4c06a93
WL
266load balancing (rlb) for IPV4 traffic, and does not require any
267special network switch support. The receive load balancing is achieved
268by ARP negotiation. The bonding driver intercepts the ARP Replies sent
269by the local system on their way out and overwrites the source
270hardware address with the unique hardware address of one of the NIC
271slaves in the single logical bonded interface such that different
272network-peers use different MAC addresses for their network packet
273traffic.
274
649098a6
EK
275If your switch support the LACP (IEEE 802.3ad) protocol then we recommend using
276the corresponding bonding mode (802.3ad). Otherwise you should generally use the
277active-backup mode. +
278// http://lists.linux-ha.org/pipermail/linux-ha/2013-January/046295.html
279If you intend to run your cluster network on the bonding interfaces, then you
280have to use active-passive mode on the bonding interfaces, other modes are
281unsupported.
b4c06a93 282
cd1de2c2
WL
283The following bond configuration can be used as distributed/shared
284storage network. The benefit would be that you get more speed and the
285network will be fault-tolerant.
286
b4c06a93
WL
287.Example: Use bond with fixed IP address
288----
289auto lo
290iface lo inet loopback
291
7a0d4784 292iface eno1 inet manual
b4c06a93 293
7a0d4784 294iface eno2 inet manual
b4c06a93
WL
295
296auto bond0
297iface bond0 inet static
7a0d4784 298 slaves eno1 eno2
b4c06a93
WL
299 address 192.168.1.2
300 netmask 255.255.255.0
301 bond_miimon 100
302 bond_mode 802.3ad
303 bond_xmit_hash_policy layer2+3
304
305auto vmbr0
306iface vmbr0 inet static
307 address 10.10.10.2
308 netmask 255.255.255.0
7ea42266 309 gateway 10.10.10.1
7a0d4784 310 bridge_ports eno1
b4c06a93
WL
311 bridge_stp off
312 bridge_fd 0
313
314----
315
cd1de2c2
WL
316
317Another possibility it to use the bond directly as bridge port.
318This can be used to make the guest network fault-tolerant.
319
320.Example: Use a bond as bridge port
b4c06a93
WL
321----
322auto lo
323iface lo inet loopback
324
7a0d4784 325iface eno1 inet manual
b4c06a93 326
7a0d4784 327iface eno2 inet manual
b4c06a93
WL
328
329auto bond0
470d4313 330iface bond0 inet manual
7a0d4784 331 slaves eno1 eno2
b4c06a93
WL
332 bond_miimon 100
333 bond_mode 802.3ad
334 bond_xmit_hash_policy layer2+3
335
336auto vmbr0
337iface vmbr0 inet static
338 address 10.10.10.2
339 netmask 255.255.255.0
7ea42266 340 gateway 10.10.10.1
b4c06a93
WL
341 bridge_ports bond0
342 bridge_stp off
343 bridge_fd 0
344
345----
346
61105e42 347
94fd8ea5
WL
348VLAN 802.1Q
349~~~~~~~~~~~
350
61105e42 351A virtual LAN (VLAN) is a broadcast domain that is partitioned
94fd8ea5
WL
352and isolated in the network at layer 2.
353So it is possible to have multiple networks (4096) in a physical network,
354each independent of the other ones.
61105e42
DM
355Each VLAN network is identified by a number often called 'tag'.
356Network packages are then 'tagged' to identify which virtual
94fd8ea5
WL
357network they belong to.
358
2a272741 359One or more VLANs can be used at any network device (NIC, Bond, Bridge).
94fd8ea5
WL
360VLANs can be configured in several ways. Here, only the most common ones get
361described. We assume a network infrastructure based on Linux Kernel Networking
362(opposed to, e.g., Open vSwitch).
363Of course, there are scenarios that are not possible with this configuration,
364but it will work for most standard setups.
365
366Two of the most common and popular usage scenarios are:
367
3681.) VLAN for the guest networks.
369Proxmox supports three different ways of using VLAN in guests:
370
371* *VLAN awareness on the Linux Bridge:*
372In this case, each guest's virtual network card is assigned to a VLAN tag,
373which is transparently supported by the Linux Bridge.
374Trunk mode is also possible, but that makes the configuration
375in the guest necessary.
376
377* *"traditional" VLAN on the Linux bridge:*
378In contrast to the VLAN awareness method, this method is not transparent
379and creates a VLAN device with associated bridge for each VLAN.
380That is, if e.g. in our default network, a guest VLAN 5 is used
381to create eno1.5 and vmbr0v5, which remains until rebooting.
382
383* *Guest configured:* The VLANs are assigned in the guest.
384In this case, the setup is in the guest and can not be influenced from the
385outside.
386The benefit is more then one VLAN on a single virtual NIC can be used.
387
3882.) VLAN on the host, to allow the host communication whit an isolated network.
389As already mentioned, it is possible to apply the VLAN to all network devices.
390In general, you should configure the VLAN on the interface with the least
391abstraction layers between itself and the physical NIC.
392
393For example, in a default configuration where you want to place
394the host management address on a separate VLAN.
395
396NOTE: In the examples we use the VLAN at bridge level to ensure the correct
397function of VLAN 5 in the guest network, but in combination with VLAN anwareness
398bridge this it will not work for guest network VLAN 5.
399The downside of this setup is more CPU usage.
400
401.Example: Use VLAN 5 for the {pve} management IP
402----
403auto lo
404iface lo inet loopback
405
406iface eno1 inet manual
407
408iface eno1.5 inet manual
409
410auto vmbr0v5
411iface vmbr0v5 inet static
412 address 10.10.10.2
413 netmask 255.255.255.0
414 gateway 10.10.10.1
415 bridge_ports eno1.5
416 bridge_stp off
417 bridge_fd 0
418
419auto vmbr0
420iface vmbr0 inet manual
421 bridge_ports eno1
422 bridge_stp off
423 bridge_fd 0
424
425----
426
427The next example is the same setup but a bond is used to
428make this network fail-safe.
429
430.Example: Use VLAN 5 with bond0 for the {pve} management IP
431----
432auto lo
433iface lo inet loopback
434
435iface eno1 inet manual
436
437iface eno2 inet manual
438
439auto bond0
440iface bond0 inet manual
441 slaves eno1 eno2
442 bond_miimon 100
443 bond_mode 802.3ad
444 bond_xmit_hash_policy layer2+3
445
446iface bond0.5 inet manual
447
448auto vmbr0v5
449iface vmbr0v5 inet static
450 address 10.10.10.2
451 netmask 255.255.255.0
452 gateway 10.10.10.1
453 bridge_ports bond0.5
454 bridge_stp off
455 bridge_fd 0
456
457auto vmbr0
458iface vmbr0 inet manual
459 bridge_ports bond0
460 bridge_stp off
461 bridge_fd 0
462
463----
464
0bcd1f7f
DM
465////
466TODO: explain IPv6 support?
470d4313 467TODO: explain OVS
0bcd1f7f 468////