Personal tools
You are here: Home Networking Linux systemd systemd-networkd v219 with a single static interface on a CentOS VM
 

systemd-networkd v219 with a single static interface on a CentOS VM

Notes on setting up a single ethernet interface with a static IPv4 and IPv6 addresses. The aim is to have a lightweight virtual machine that boots simply and quickly.

 

Network Manager

Remove network manager.

# yum erase NetworkManager NetworkManager-libnm NetworkManager-glib

Networkd

Install systemd packages

# yum install systemd-networkd systemd-resolved

Configure the single network interface with a static address:

# mkdir -p /etc/systemd/network
# cat > /etc/systemd/network/10-static-eth0.network<<EOF
[Match]
Name=eth0

[Link]
MTUBytes=9000

[Network]
Address=10.20.17.3/24
Gateway=10.20.17.1

Address=fd0c:898b:471c:11::3/64
Address=2001:4428:225:11::3/64
Gateway=fe80::1
IPv6AcceptRouterAdvertisements=no

LLMNR=no
DNS=fd0c:898b:471c:2::5 fd0c:898b:471c:c::2 10.20.2.5 10.20.12.2 

EOF

 

Note:  The IPv6 link local gateway does not support or require an interface specified (i.e. a '%eth0' suffix).

Note: IPv6AcceptRouterAdvertisements=no is not valid for systemd v219

Enable and start the 'networkd' and 'resolved' services:

# for S in networkd resolved ; do systemctl enable systemd-$S ; systemctl start systemd-$S ; done

Resolv.conf

# rm /etc/resolv.conf
# ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

 

Links

Appendices

Install

# yum install systemd-networkd systemd-resolved
Resolving Dependencies
--> Running transaction check
---> Package systemd-networkd.x86_64 0:219-19.el7_2.7 will be installed
---> Package systemd-resolved.x86_64 0:219-19.el7_2.7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                    Arch             Version                   Repository         Size
===============================================================================================
Installing:
 systemd-networkd           x86_64           219-19.el7_2.7            updates           423 k
 systemd-resolved           x86_64           219-19.el7_2.7            updates           395 k

Transaction Summary
===============================================================================================
Install  2 Packages

Total download size: 818 k
Installed size: 2.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): systemd-networkd-219-19.el7_2.7.x86_64.rpm                       | 423 kB  00:00:00
(2/2): systemd-resolved-219-19.el7_2.7.x86_64.rpm                       | 395 kB  00:00:00
-----------------------------------------------------------------------------------------------
Total                                                          798 kB/s | 818 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : systemd-networkd-219-19.el7_2.7.x86_64                                      1/2
  Installing : systemd-resolved-219-19.el7_2.7.x86_64                                      2/2
  Verifying  : systemd-resolved-219-19.el7_2.7.x86_64                                      1/2
  Verifying  : systemd-networkd-219-19.el7_2.7.x86_64                                      2/2

Installed:
  systemd-networkd.x86_64 0:219-19.el7_2.7       systemd-resolved.x86_64 0:219-19.el7_2.7

Complete!

networkd status

# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2016-04-05 22:59:16 NZST; 1min 55s ago
     Docs: man:systemd-networkd.service(8)
  Process: 439 ExecStart=/usr/lib/systemd/systemd-networkd (code=exited, status=0/SUCCESS)
 Main PID: 439 (code=exited, status=0/SUCCESS)
   Status: "Shutting down..."

Apr 05 22:58:44 bakerschocolate.lucidsolutions.co.nz systemd[1]: Starting Network Service...
Apr 05 22:58:44 bakerschocolate.lucidsolutions.co.nz systemd-networkd[439]: Enumeration completed
Apr 05 22:58:44 bakerschocolate.lucidsolutions.co.nz systemd[1]: Started Network Service.
Apr 05 22:58:44 bakerschocolate.lucidsolutions.co.nz systemd-networkd[439]: eth0            : gained carrier
Apr 05 22:58:44 bakerschocolate.lucidsolutions.co.nz systemd-networkd[439]: eth0            : link configured

resolved status

# systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2016-04-05 22:37:31 NZST; 5min ago
     Docs: man:systemd-resolved.service(8)
 Main PID: 598 (systemd-resolve)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-resolved.service
           └─598 /usr/lib/systemd/systemd-resolved

Apr 05 22:37:31 bakerschocolate.lucidsolutions.co.nz systemd[1]: Starting Network Name Resolution...
Apr 05 22:37:31 bakerschocolate.lucidsolutions.co.nz systemd-resolved[598]: Using system hostname 
    'bakerschocolate.lucidsolutions.co.nz'.
Apr 05 22:37:31 bakerschocolate.lucidsolutions.co.nz systemd-resolved[598]: Switching to system 
    DNS server fd0c:898b:471c:2::5.
Apr 05 22:37:31 bakerschocolate.lucidsolutions.co.nz systemd[1]: Started Network Name Resolution.

 

Document Actions