This post will describe how to convert NetworkManager to networkd.
I am using Fedora Workstation 24 image. If you are using fedora or projectatomic cloud images you can use networkd there.
Switching from NetworkManager to networkd:
We need to make sure that NetworkManager and networkd don’t start on reboot.
# systemctl disable NetworkManager # systemctl disable network
Now Ensure that systemd-networkd starts on the next boot:
# systemctl enable systemd-networkd
Enable the resolver and make a symlink:
# systemctl enable systemd-resolved # systemctl start systemd-resolved # rm -f /etc/resolv.conf # ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Configure your network interfaces in /etc/systemd/network and then reboot.
Some sample use cases for systemd-networkd and example configurations are below:
Simple DHCP on single interface
For an interface eth0
, a single .network
file is needed
# cat /etc/systemd/network/eth0.network [Match] Name=eth0 [Network] DHCP=yes
Bridging
Here we have eth0 and we want to add it to a bridge. This could be handy for servers where you want to build containers or virtual machines and attach them to the network bridge.
We will start with setting up bridge interface br0
.
# cat /etc/systemd/network/br0.netdev [NetDev] Name=br0 Kind=bridge
Let’s configure the network for the bridge
# cat /etc/systemd/network/br0.network [Match] Name=br0 [Network] IPForward=yes DHCP=yes
The IPForward=yes will take care of the systemctl forwarding setting for us (net.ipv4.conf.br0.forwarding = 1) automatically when the interface comes up.
Now take ethernet adapter and add it to bridge
# cat /etc/systemd/network/eth0.network [Match] Name=eth0 [Network] Bridge=br0
Now reboot the system and it will come up with eth0 as a port on br0.
Bonding
Let’s configure a bonding interface which is similar to that of a bridge. Start by setting up individual network adapters.
# cat /etc/systemd/network/ens9f0.network [Match] Name=ens9f0 [Network] Bond=bond1
# cat /etc/systemd/network/ens9f1.network [Match] Name=ens9f1 [Network] Bond=bond1
Create network device for the bond
# /etc/systemd/network/bond1.netdev [NetDev] Name=bond1 Kind=bond [Bond] Mode=802.3ad TransmitHashPolicy=layer3+4 MIIMonitorSec=1s LACPTransmitRate=fast
Add networking to the device
# /etc/systemd/network/bond1.network [Match] Name=bond1 [Network] DHCP=yes BindCarrier=ens9f0 ens9f1
The BindCarrier is optional but recommended. It gives systemd-networkd the hint that if both bonded interfaces are offline, it should remove the bond configuration until one of the interfaces comes up again.
Check Status
Output from systemd-netword will appear in system journal. The networkctl
command allows to check your network devices at a glance.
Here’s an example of the network setup we just created:
Further Reading: http://fedoracloud.readthedocs.io/en/latest/networkd.html
[…] #systemd spreading https://trishnag.wordpress.com/2016/08/09/how-to-convert-networkmanager-to-networkd/ […]
LikeLike
[…] How to Convert NetworkManager to networkd […]
LikeLike