]> git.proxmox.com Git - pve-docs.git/blame - pve-network.adoc
add SHA512 checksum for repository key
[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
cc3cb912 44* Legacy Ethernet devices: eth[N], where 0 ≤ N (`eth0`, `eth1`, ...)
7a0d4784 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
cc3cb912 57
7a0d4784
WL
58Systemd Network Interface Names
59^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60
8116dea5
DM
61Systemd uses the two character prefix 'en' for Ethernet network
62devices. The next characters depends on the device driver and the fact
cc3cb912 63which schema matches first.
7a0d4784
WL
64
65* o<index>[n<phys_port_name>|d<dev_port>] — devices on board
66
67* s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — device by hotplug id
68
69* [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — devices by bus id
70
71* x<MAC> — device by MAC address
72
cc3cb912 73The most common patterns are:
7a0d4784
WL
74
75* eno1 — is the first on board NIC
76
77* enp3s0f1 — is the NIC on pcibus 3 slot 0 and use the NIC function 1.
78
cc3cb912
DM
79For more information see https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/[Predictable Network Interface Names].
80
7a0d4784 81
0bcd1f7f
DM
82Default Configuration using a Bridge
83~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
85The installation program creates a single bridge named `vmbr0`, which
8116dea5 86is connected to the first Ethernet card `eno0`. The corresponding
8c1189b6 87configuration in `/etc/network/interfaces` looks like this:
0bcd1f7f
DM
88
89----
90auto lo
91iface lo inet loopback
92
7a0d4784 93iface eno1 inet manual
0bcd1f7f
DM
94
95auto vmbr0
96iface vmbr0 inet static
97 address 192.168.10.2
98 netmask 255.255.255.0
99 gateway 192.168.10.1
7a0d4784 100 bridge_ports eno1
0bcd1f7f
DM
101 bridge_stp off
102 bridge_fd 0
103----
104
105Virtual machines behave as if they were directly connected to the
106physical network. The network, in turn, sees each virtual machine as
107having its own MAC, even though there is only one network cable
108connecting all of these VMs to the network.
109
110
111Routed Configuration
112~~~~~~~~~~~~~~~~~~~~
113
114Most hosting providers do not support the above setup. For security
115reasons, they disable networking as soon as they detect multiple MAC
116addresses on a single interface.
117
118TIP: Some providers allows you to register additional MACs on there
119management interface. This avoids the problem, but is clumsy to
120configure because you need to register a MAC for each of your VMs.
121
8c1189b6 122You can avoid the problem by ``routing'' all traffic via a single
0bcd1f7f
DM
123interface. This makes sure that all network packets use the same MAC
124address.
125
8c1189b6 126A common scenario is that you have a public IP (assume `192.168.10.2`
0bcd1f7f 127for this example), and an additional IP block for your VMs
8c1189b6 128(`10.10.10.1/255.255.255.0`). We recommend the following setup for such
0bcd1f7f
DM
129situations:
130
131----
132auto lo
133iface lo inet loopback
134
7a0d4784
WL
135auto eno1
136iface eno1 inet static
0bcd1f7f
DM
137 address 192.168.10.2
138 netmask 255.255.255.0
139 gateway 192.168.10.1
7a0d4784 140 post-up echo 1 > /proc/sys/net/ipv4/conf/eno1/proxy_arp
0bcd1f7f
DM
141
142
143auto vmbr0
144iface vmbr0 inet static
145 address 10.10.10.1
146 netmask 255.255.255.0
147 bridge_ports none
148 bridge_stp off
149 bridge_fd 0
150----
151
152
8c1189b6
FG
153Masquerading (NAT) with `iptables`
154~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0bcd1f7f
DM
155
156In some cases you may want to use private IPs behind your Proxmox
157host's true IP, and masquerade the traffic using NAT:
158
159----
160auto lo
161iface lo inet loopback
162
7a0d4784 163auto eno0
0bcd1f7f 164#real IP adress
7a0d4784 165iface eno1 inet static
0bcd1f7f
DM
166 address 192.168.10.2
167 netmask 255.255.255.0
168 gateway 192.168.10.1
169
170auto vmbr0
171#private sub network
172iface vmbr0 inet static
173 address 10.10.10.1
174 netmask 255.255.255.0
175 bridge_ports none
176 bridge_stp off
177 bridge_fd 0
178
179 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784
WL
180 post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
181 post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
0bcd1f7f
DM
182----
183
b4c06a93
WL
184
185Linux Bond
186~~~~~~~~~~
187
3eafe338
WL
188Bonding (also called NIC teaming or Link Aggregation) is a technique
189for binding multiple NIC's to a single network device. It is possible
190to achieve different goals, like make the network fault-tolerant,
191increase the performance or both together.
192
193High-speed hardware like Fibre Channel and the associated switching
194hardware can be quite expensive. By doing link aggregation, two NICs
195can appear as one logical interface, resulting in double speed. This
196is a native Linux kernel feature that is supported by most
197switches. If your nodes have multiple Ethernet ports, you can
198distribute your points of failure by running network cables to
199different switches and the bonded connection will failover to one
200cable or the other in case of network trouble.
201
202Aggregated links can improve live-migration delays and improve the
203speed of replication of data between Proxmox VE Cluster nodes.
b4c06a93
WL
204
205There are 7 modes for bonding:
206
207* *Round-robin (balance-rr):* Transmit network packets in sequential
208order from the first available network interface (NIC) slave through
209the last. This mode provides load balancing and fault tolerance.
210
211* *Active-backup (active-backup):* Only one NIC slave in the bond is
212active. A different slave becomes active if, and only if, the active
213slave fails. The single logical bonded interface's MAC address is
214externally visible on only one NIC (port) to avoid distortion in the
215network switch. This mode provides fault tolerance.
216
217* *XOR (balance-xor):* Transmit network packets based on [(source MAC
218address XOR'd with destination MAC address) modulo NIC slave
219count]. This selects the same NIC slave for each destination MAC
220address. This mode provides load balancing and fault tolerance.
221
222* *Broadcast (broadcast):* Transmit network packets on all slave
223network interfaces. This mode provides fault tolerance.
224
225* *IEEE 802.3ad Dynamic link aggregation (802.3ad)(LACP):* Creates
226aggregation groups that share the same speed and duplex
227settings. Utilizes all slave network interfaces in the active
228aggregator group according to the 802.3ad specification.
229
230* *Adaptive transmit load balancing (balance-tlb):* Linux bonding
231driver mode that does not require any special network-switch
232support. The outgoing network packet traffic is distributed according
233to the current load (computed relative to the speed) on each network
234interface slave. Incoming traffic is received by one currently
235designated slave network interface. If this receiving slave fails,
236another slave takes over the MAC address of the failed receiving
237slave.
238
e60ce90c 239* *Adaptive load balancing (balance-alb):* Includes balance-tlb plus receive
b4c06a93
WL
240load balancing (rlb) for IPV4 traffic, and does not require any
241special network switch support. The receive load balancing is achieved
242by ARP negotiation. The bonding driver intercepts the ARP Replies sent
243by the local system on their way out and overwrites the source
244hardware address with the unique hardware address of one of the NIC
245slaves in the single logical bonded interface such that different
246network-peers use different MAC addresses for their network packet
247traffic.
248
249For the most setups the active-backup are the best choice or if your
250switch support LACP "IEEE 802.3ad" this mode should be preferred.
251
cd1de2c2
WL
252The following bond configuration can be used as distributed/shared
253storage network. The benefit would be that you get more speed and the
254network will be fault-tolerant.
255
b4c06a93
WL
256.Example: Use bond with fixed IP address
257----
258auto lo
259iface lo inet loopback
260
7a0d4784 261iface eno1 inet manual
b4c06a93 262
7a0d4784 263iface eno2 inet manual
b4c06a93
WL
264
265auto bond0
266iface bond0 inet static
7a0d4784 267 slaves eno1 eno2
b4c06a93
WL
268 address 192.168.1.2
269 netmask 255.255.255.0
270 bond_miimon 100
271 bond_mode 802.3ad
272 bond_xmit_hash_policy layer2+3
273
274auto vmbr0
275iface vmbr0 inet static
276 address 10.10.10.2
277 netmask 255.255.255.0
278 gateway 10.10.10.1
7a0d4784 279 bridge_ports eno1
b4c06a93
WL
280 bridge_stp off
281 bridge_fd 0
282
283----
284
cd1de2c2
WL
285
286Another possibility it to use the bond directly as bridge port.
287This can be used to make the guest network fault-tolerant.
288
289.Example: Use a bond as bridge port
b4c06a93
WL
290----
291auto lo
292iface lo inet loopback
293
7a0d4784 294iface eno1 inet manual
b4c06a93 295
7a0d4784 296iface eno2 inet manual
b4c06a93
WL
297
298auto bond0
299iface bond0 inet maunal
7a0d4784 300 slaves eno1 eno2
b4c06a93
WL
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
309 gateway 10.10.10.1
310 bridge_ports bond0
311 bridge_stp off
312 bridge_fd 0
313
314----
315
0bcd1f7f
DM
316////
317TODO: explain IPv6 support?
318TODO: explan OVS
319////