From 9e35b3de429890ed836271dc0ccbd821ab0c204a Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 2 Dec 2016 14:00:46 -0500 Subject: man: make the examples in systemd.network(5) more useful We shouldn't just have snippets of configuration, but instead examples which show all the parts necessary to build a certain kind of setup, with short explanations. --- man/systemd.network.xml | 188 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 130 insertions(+), 58 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 53c49f817f..3a366a573b 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -608,47 +608,57 @@ Bridge= - The name of the bridge to add the link to. + The name of the bridge to add the link to. See + systemd.netdev5. + Bond= - The name of the bond to add the link to. + The name of the bond to add the link to. See + systemd.netdev5. + VRF= - The name of the VRF to add the link to. + The name of the VRF to add the link to. See + systemd.netdev5. + VLAN= - The name of a VLAN to create on the link. This - option may be specified more than once. + The name of a VLAN to create on the link. See + systemd.netdev5. + This option may be specified more than once. MACVLAN= - The name of a MACVLAN to create on the link. This - option may be specified more than once. + The name of a MACVLAN to create on the link. See + systemd.netdev5. + This option may be specified more than once. VXLAN= - The name of a VXLAN to create on the link. This - option may be specified more than once. + The name of a VXLAN to create on the link. See + systemd.netdev5. + This option may be specified more than once. Tunnel= - The name of a Tunnel to create on the link. This - option may be specified more than once. + The name of a Tunnel to create on the link. See + systemd.netdev5. + This option may be specified more than once. @@ -1287,53 +1297,75 @@ - Example + Examples - /etc/systemd/network/50-static.network + Static network configuration - [Match] + # /etc/systemd/network/50-static.network +[Match] Name=enp2s0 [Network] Address=192.168.0.15/24 Gateway=192.168.0.1 + + This brings interface enp2s0 up with a static address. The + specified gateway will be used for a default route. - /etc/systemd/network/80-dhcp.network + DHCP on ethernet links - [Match] + # /etc/systemd/network/80-dhcp.network +[Match] Name=en* [Network] DHCP=yes + + This will enable DHCPv4 and DHCPv6 on all interfaces with names starting with + en (i.e. ethernet interfaces). - /etc/systemd/network/25-bridge-static.network + A bridge with two enslaved links - [Match] + # /etc/systemd/network/25-bridge-static.network +[Match] Name=bridge0 [Network] Address=192.168.0.15/24 Gateway=192.168.0.1 DNS=192.168.0.1 - - - - /etc/systemd/network/25-bridge-slave-interface.network - [Match] + # /etc/systemd/network/25-bridge-slave-interface-1.network +[Match] Name=enp2s0 [Network] Bridge=bridge0 + + # /etc/systemd/network/25-bridge-slave-interface-2.network +[Match] +Name=wlp3s0 + +[Network] +Bridge=bridge0 + + This creates a bridge and attaches devices enp2s0 and + wlp3s0 to it. The bridge will have the specified static address + and network assigned, and a default route via the specified gateway will be + added. The specified DNS server will be added to the global list of DNS resolvers. + + - /etc/systemd/network/25-bridge-slave-interface-vlan.network + - [Match] + +# /etc/systemd/network/20-bridge-slave-interface-vlan.network +[Match] Name=enp2s0 [Network] @@ -1349,66 +1381,106 @@ VLAN=100-200 [BridgeVLAN] EgressUntagged=300-400 - - - /etc/systemd/network/25-ipip.network - - [Match] -Name=em1 -[Network] -Tunnel=ipip-tun + This overrides the configuration specified in the previous example for the + interface enp2s0, and enables VLAN on that bridge port. VLAN IDs + 1-32, 42, 100-400 will be allowed. Packets tagged with VLAN IDs 42, 300-400 will be + untagged when they leave on this interface. Untagged packets which arrive on this + interface will be assigned VLAN ID 42. - /etc/systemd/network/25-sit.network + Various tunnels - [Match] -Name=em1 + /etc/systemd/network/25-tunnels.network +[Match] +Name=ens1 [Network] -Tunnel=sit-tun +Tunnel=ipip-tun +Tunnel=sit-tun +Tunnel=gre-tun +Tunnel=vti-tun + + + /etc/systemd/network/25-tunnel-ipip.netdev +[NetDev] +Name=ipip-tun +Kind=ipip + + + /etc/systemd/network/25-tunnel-sit.netdev +[NetDev] +Name=sit-tun +Kind=sit + + + /etc/systemd/network/25-tunnel-gre.netdev +[NetDev] +Name=gre-tun +Kind=gre + + + /etc/systemd/network/25-tunnel-vti.netdev +[NetDev] +Name=vti-tun +Kind=vti + + + This will bring interface ens1 up and create an IPIP tunnel, + a SIT tunnel, a GRE tunnel, and a VTI tunnel using it. - /etc/systemd/network/25-gre.network + A bond device - [Match] -Name=em1 + # /etc/systemd/network/30-bond1.network +[Match] +Name=bond1 [Network] -Tunnel=gre-tun - +DHCP=ipv6 + - - /etc/systemd/network/25-vti.network + # /etc/systemd/network/30-bond1.netdev +[NetDev] +Name=bond1 +Kind=bond + - [Match] -Name=em1 + # /etc/systemd/network/30-bond1-dev1.nework +[Match] +MACAddress=52:54:00:e9:64:41 [Network] -Tunnel=vti-tun - - - - /etc/systemd/network/25-bond.network +Bond=bond1 + - [Match] -Name=bond1 + # /etc/systemd/network/30-bond1-dev2.nework +[Match] +MACAddress=52:54:00:e9:64:42 [Network] -DHCP=yes +Bond=bond1 + + This will create a bond device bond1 and enslave the two + devices with MAC addresses 52:54:00:e9:64:41 and 52:54:00:e9:64:42 to it. IPv6 DHCP + will be used to acquire an address. - /etc/systemd/network/25-vrf.network - Add the bond1 interface to the VRF master interface vrf-test. This will redirect routes generated on this interface to be within the routing table defined during VRF creation. Traffic won't be redirected towards the VRFs routing table unless specific ip-rules are added. - [Match] + Virtual Routing and Forwarding (VRF) + Add the bond1 interface to the VRF master interface + vrf1. This will redirect routes generated on this interface to be + within the routing table defined during VRF creation. Traffic won't be redirected + towards the VRFs routing table unless specific ip-rules are added. + # /etc/systemd/network/25-vrf.network +[Match] Name=bond1 [Network] -VRF=vrf-test +VRF=vrf1 -- cgit v1.2.3-54-g00ecf