Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   systemd.network    ( 5 )

конфигурация сети (Network configuration)

  Name  |  Synopsis  |  Description  |  Match section options  |  [link] section options  |  [sr-iov] section options  |  Network section options  |  [address] section options  |  [neighbor] section options  |  [ipv6addresslabel] section options  |  [routingpolicyrule] section options  |  [nexthop] section options  |  [route] section options  |  Dhcpv4 section options  |  Dhcpv6 section options  |  [dhcpv6prefixdelegation] section options  |  [ipv6acceptra] section options  |  [dhcpserver] section options  |  [dhcpserverstaticlease] section options  |  [ipv6sendra] section options  |  [ipv6prefix] section options  |  [ipv6routeprefix] section options  |  [bridge] section options  |  [bridgefdb] section options  |  [bridgemdb] section options  |  [lldp] section options  |  [can] section options  |  [qdisc] section options  |  [networkemulator] section options  |  [tokenbucketfilter] section options  |  [pie] section options  |  [flowqueuepie] section options  |  [stochasticfairblue] section options  |  [stochasticfairnessqueueing] section options  |  [bfifo] section options  |  [pfifo] section options  |  [pfifoheaddrop] section options  |  [pfifofast] section options  |  [cake] section options  |  [controlleddelay] section options  |  [deficitroundrobinscheduler] section options  |  [deficitroundrobinschedulerclass] section options  |  [enhancedtransmissionselection] section options  |  [genericrandomearlydetection] section options  |  [fairqueueingcontrolleddelay] section options  |  [fairqueueing] section options  |  [triviallinkequalizer] section options  |  [hierarchytokenbucket] section options  |  [hierarchytokenbucketclass] section options  |  [heavyhitterfilter] section options  |  [quickfairqueueing] section options  |  [quickfairqueueingclass] section options  |  [bridgevlan] section options  |    Examples    |  See also  |  Note  |

Примеры (Examples)

Example 1. Static network configuration

# /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.

Example 2. DHCP on ethernet links

# /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).

Example 3. IPv6 Prefix Delegation

# /etc/systemd/network/55-ipv6-pd-upstream.network [Match] Name=enp1s0

[Network] DHCP=ipv6

# /etc/systemd/network/56-ipv6-pd-downstream.network [Match] Name=enp2s0

[Network] IPv6SendRA=yes DHCPv6PrefixDelegation=yes

This will enable DHCPv6-PD on the interface enp1s0 as an upstream interface where the DHCPv6 client is running and enp2s0 as a downstream interface where the prefix is delegated to. The delegated prefixes are distributed by IPv6 Router Advertisement on the downstream network.

Example 4. A bridge with two enslaved links

# /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-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.

Example 5.

# /etc/systemd/network/20-bridge-slave-interface-vlan.network [Match] Name=enp2s0

[Network] Bridge=bridge0

[BridgeVLAN] VLAN=1-32 PVID=42 EgressUntagged=42

[BridgeVLAN] VLAN=100-200

[BridgeVLAN] EgressUntagged=300-400

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.

Example 6. Various tunnels

/etc/systemd/network/25-tunnels.network [Match] Name=ens1

[Network] 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.

Example 7. A bond device

# /etc/systemd/network/30-bond1.network [Match] Name=bond1

[Network] DHCP=ipv6

# /etc/systemd/network/30-bond1.netdev [NetDev] Name=bond1 Kind=bond

# /etc/systemd/network/30-bond1-dev1.network [Match] MACAddress=52:54:00:e9:64:41

[Network] Bond=bond1

# /etc/systemd/network/30-bond1-dev2.network [Match] MACAddress=52:54:00:e9:64:42

[Network] 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.

Example 8. 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. For kernels before 4.8 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=vrf1

Example 9. MacVTap

This brings up a network interface "macvtap-test" and attaches it to "enp0s25".

# /usr/lib/systemd/network/25-macvtap.network [Match] Name=enp0s25

[Network] MACVTAP=macvtap-test

Example 10. A Xfrm interface with physical underlying device.

# /etc/systemd/network/27-xfrm.netdev [NetDev] Name=xfrm0

[Xfrm] InterfaceId=7

# /etc/systemd/network/27-eth0.network [Match] Name=eth0

[Network] Xfrm=xfrm0

This creates a "xfrm0" interface and binds it to the "eth0" device. This allows hardware based ipsec offloading to the "eth0" nic. If offloading is not needed, xfrm interfaces can be assigned to the "lo" device.