]> git.proxmox.com Git - pve-docs.git/blame - pve-network.adoc
qm.adoc: style/grammar
[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
44f38275 23whole network setup. Please refer to the 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
04e8476d
EK
86is connected to the first Ethernet card. The corresponding
87configuration in `/etc/network/interfaces` might look 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
1ed90852 140 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784 141 post-up echo 1 > /proc/sys/net/ipv4/conf/eno1/proxy_arp
0bcd1f7f
DM
142
143
144auto vmbr0
145iface vmbr0 inet static
146 address 10.10.10.1
147 netmask 255.255.255.0
148 bridge_ports none
149 bridge_stp off
150 bridge_fd 0
151----
152
153
8c1189b6
FG
154Masquerading (NAT) with `iptables`
155~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0bcd1f7f
DM
156
157In some cases you may want to use private IPs behind your Proxmox
158host's true IP, and masquerade the traffic using NAT:
159
160----
161auto lo
162iface lo inet loopback
163
7a0d4784 164auto eno0
470d4313 165#real IP address
7a0d4784 166iface eno1 inet static
0bcd1f7f
DM
167 address 192.168.10.2
168 netmask 255.255.255.0
169 gateway 192.168.10.1
170
171auto vmbr0
172#private sub network
173iface vmbr0 inet static
174 address 10.10.10.1
175 netmask 255.255.255.0
176 bridge_ports none
177 bridge_stp off
178 bridge_fd 0
179
180 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
7a0d4784
WL
181 post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
182 post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eno1 -j MASQUERADE
0bcd1f7f
DM
183----
184
b4c06a93
WL
185
186Linux Bond
187~~~~~~~~~~
188
3eafe338
WL
189Bonding (also called NIC teaming or Link Aggregation) is a technique
190for binding multiple NIC's to a single network device. It is possible
191to achieve different goals, like make the network fault-tolerant,
192increase the performance or both together.
193
194High-speed hardware like Fibre Channel and the associated switching
195hardware can be quite expensive. By doing link aggregation, two NICs
196can appear as one logical interface, resulting in double speed. This
197is a native Linux kernel feature that is supported by most
198switches. If your nodes have multiple Ethernet ports, you can
199distribute your points of failure by running network cables to
200different switches and the bonded connection will failover to one
201cable or the other in case of network trouble.
202
203Aggregated links can improve live-migration delays and improve the
204speed of replication of data between Proxmox VE Cluster nodes.
b4c06a93
WL
205
206There are 7 modes for bonding:
207
208* *Round-robin (balance-rr):* Transmit network packets in sequential
209order from the first available network interface (NIC) slave through
210the last. This mode provides load balancing and fault tolerance.
211
212* *Active-backup (active-backup):* Only one NIC slave in the bond is
213active. A different slave becomes active if, and only if, the active
214slave fails. The single logical bonded interface's MAC address is
215externally visible on only one NIC (port) to avoid distortion in the
216network switch. This mode provides fault tolerance.
217
218* *XOR (balance-xor):* Transmit network packets based on [(source MAC
219address XOR'd with destination MAC address) modulo NIC slave
220count]. This selects the same NIC slave for each destination MAC
221address. This mode provides load balancing and fault tolerance.
222
223* *Broadcast (broadcast):* Transmit network packets on all slave
224network interfaces. This mode provides fault tolerance.
225
226* *IEEE 802.3ad Dynamic link aggregation (802.3ad)(LACP):* Creates
227aggregation groups that share the same speed and duplex
228settings. Utilizes all slave network interfaces in the active
229aggregator group according to the 802.3ad specification.
230
231* *Adaptive transmit load balancing (balance-tlb):* Linux bonding
232driver mode that does not require any special network-switch
233support. The outgoing network packet traffic is distributed according
234to the current load (computed relative to the speed) on each network
235interface slave. Incoming traffic is received by one currently
236designated slave network interface. If this receiving slave fails,
237another slave takes over the MAC address of the failed receiving
238slave.
239
e60ce90c 240* *Adaptive load balancing (balance-alb):* Includes balance-tlb plus receive
b4c06a93
WL
241load balancing (rlb) for IPV4 traffic, and does not require any
242special network switch support. The receive load balancing is achieved
243by ARP negotiation. The bonding driver intercepts the ARP Replies sent
244by the local system on their way out and overwrites the source
245hardware address with the unique hardware address of one of the NIC
246slaves in the single logical bonded interface such that different
247network-peers use different MAC addresses for their network packet
248traffic.
249
649098a6
EK
250If your switch support the LACP (IEEE 802.3ad) protocol then we recommend using
251the corresponding bonding mode (802.3ad). Otherwise you should generally use the
252active-backup mode. +
253// http://lists.linux-ha.org/pipermail/linux-ha/2013-January/046295.html
254If you intend to run your cluster network on the bonding interfaces, then you
255have to use active-passive mode on the bonding interfaces, other modes are
256unsupported.
b4c06a93 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
7ea42266 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
470d4313 305iface bond0 inet manual
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
7ea42266 315 gateway 10.10.10.1
b4c06a93
WL
316 bridge_ports bond0
317 bridge_stp off
318 bridge_fd 0
319
320----
321
0bcd1f7f
DM
322////
323TODO: explain IPv6 support?
470d4313 324TODO: explain OVS
0bcd1f7f 325////