From Mageia wiki
Jump to: navigation, search
Note:
Simple network setup guide for wired interfaces with builtin systemd tools.

Introduction

Systemd got builtin tools for getting your wired network working. Both systemd-networkd and systemd-resolved are part of the systemd package and are already installed. You will need to start both of them to get your network working properly.

Configuration

First find out what your interface is called. Usually the first one found is called enp3s0.

# networkctl

Create the directory for systemd-networkd configuration files:

# mkdir -p /etc/systemd/network

And create a .network file, e.g. home.network.

# nano -w /etc/systemd/network/home.network

Systemd-networkd

DHCP

The following lines should be enough for using DHCP.

[Match]
Name = enp3s0

[Network]
Description = Home Network
DHCP = yes

Static IP

(TODO)

Systemd-resolved (DNS)

To use systemd-resolved for DNS, create a symbolic link:

# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

If you don't receive the nameservers via DHCP, add a

DNS=

entry to the .network file.

Now when everything is configured properly you can start both services. You may also need to first stop the legacy network service.

# systemctl start systemd-metworkd
# systemctl start systemd-resolved

And check that the network is working woth the ping tool.

$ ping mageia.org

Network Interface Names

Before going into the configuration, it's important to know more about the names of the network interfaces.

To identify the available network interfaces, execute the command:

# ls /sys/class/net

or

# ip link show

The naming of the interfaces is described in the Predictable Network Interface Names scheme. For more information visit:

The kernel is responsible for recognizing hardware, after that it will hand it over to systemd-udev and this process loads the necessary driver and names the network interface.
The following command will give you all the details:

# udevadm info /sys/class/net/<device name>

The ip command

The ip command can give you more information about the device:

# ip -d link show <device name>

And about the ip address that is configured on the interface:

# ip address show dev <device name>

And shows the default gateway:

# ip route show 0.0.0.0/0

You can do many other things with the ip command, such as assigning an ip address to a network interface, add/change routes etc. But everything you'll do is not persistent across reboots.

That's why you need a Network Manager such as NetworkManager or systemd-networkd.

network service (Mageia legacy)

The network service is used to configure your network. If you configure your network via the Mageia Control Center, the configuration is saved in a /etc/sysconfig/network-scripts/ifcfg-<device name> file. These configuration files are parsed at boot-time via the network service (/etc/rc.d/init.d/network).

As an example of the content:

DEVICE=enp3s0f1
BOOTPROTO=dhcp
ONBOOT=yes

In the example above, the device name is enp3s0f1.

If you know what you are doing, you can also manually make changes in this file, or even create your own configuration files.

The good news about this configuration is that it is compatible with NetworkManager, just add:

NM_CONTROLLED=yes

However the network service is not very flexible and sometimes hard to configure in more complex environments.

systemd-networkd migration

If you migrated everything (!) to systemd-networkd you can stop using the network service:

# systemctl stop network
# systemctl disable network
# systemctl mask network
# systemctl stop network-up
# systemctl disable network-up

But: Use this option only if you really need the flexibility or you want to get more knowledge about systemd!!!

DNS

The network service updates /etc/resolv.conf. That file configures the nameserver for resolving and your search domain.

You can use the nslookup, dig or host utility to verify the resolving.

If you disabled the network service, you'll need to configure systemd-resolved.

Hostname

You can configure the hostname during the installation of Mageia. It will write the configuration to the file /etc/hostname

Alternatively you can use the hostname command.

First check the current name:

# hostnamectl

And change it with:

# hostnamectl set-hostname <full qualified hostname>

As an alternative, manahost is available, which is part of the manatools package.

See also

Switching_to_networkmanager