This section only applies if a network card is to be configured.
Starting with version 209, systemd ships a network configuration
daemon called systemd-networkd which can be
used for basic network configuration. Additionally, since version
213, DNS name resolution can be handled by systemd-resolved in place of a
/etc/resolv.conf file. Both
services are enabled by defualt, and absolutely should not be
Configuration files for systemd-networkd (and
be placed in
/etc/systemd/network. Files in
/etc/systemd/network have a higher
priority than the ones in
/usr/lib/systemd/network. There are three types
of configuration files:
.network files. For detailed descriptions and
example contents of these configuration files, consult the
systemd-network(5) manual pages.
Udev may assign network card interface names based on system physical characteristics such as enp2s1. If you are not sure what your interface name is, you can always run ip link after you have booted your system.
The command below creates a basic configuration file for a Static IP setup (using both systemd-networkd and systemd-resolved):
cat > /etc/systemd/network/10-eth0-static.network << "EOF"
[Match] Name=eth0 [Network] Address=192.168.0.2/24 Gateway=192.168.0.1 DNS=192.168.0.1EOF
Multiple DNS entries can be added if you have more than one DNS server.
If the system is going to be connected to the Internet, it will
need some means of Domain Name Service (DNS) name resolution to
resolve Internet domain names to IP addresses, and vice versa. This
is best achieved by placing the IP address of the DNS server,
available from the ISP or network administrator, into
If using another means to configure your network interfaces
(ex: ppp, network-manager, etc.), or if using any type of local
resolver (ex: bind, dnsmasq, etc.), or any other software that
(ex: resolvconf), the systemd-resolved service
should not be used.
When using systemd-resolved for DNS
configuration, it is responsible for creating the
/etc/resolv.conf file. Since version 226, the
created by systemd when needed, so no further configuration is
If a static
desired, create it by running the following command:
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf domainEOF
<Your Domain Name>nameserver
<IP address of your primary nameserver>nameserver
<IP address of your secondary nameserver># End /etc/resolv.conf
domain statement can be omitted
or replaced with a
See the man page for resolv.conf for more details.
<IP address of the
nameserver> with the IP address of the DNS most
appropriate for the setup. There will often be more than one
entry (requirements demand secondary servers for fallback
capability). If you only need or want one DNS server, remove the
second nameserver line
from the file. The IP address may also be a router on the local
The Google Public IPv4 DNS addresses are
18.104.22.168 for IPv4, and
During the boot process, the file
/etc/hostname is used for establishing the
/etc/hostname file and
enter a hostname by running:
<lfs>" > /etc/hostname
<lfs> needs to be
replaced with the name given to the computer. Do not enter the
Fully Qualified Domain Name (FQDN) here. That information is put in
Decide on the IP address, fully-qualified domain name (FQDN), and
possible aliases for use in the
/etc/hosts file. The syntax is:
IP_address myhost.example.org aliases
Unless the computer is to be visible to the Internet (i.e., there is a registered domain and a valid block of assigned IP addresses—most users do not have this), make sure that the IP address is in the private network IP address range. Valid ranges are:
Private Network Address Range Normal Prefix 10.0.0.1 - 10.255.255.254 8 172.x.0.1 - 172.x.255.254 16 192.168.y.1 - 192.168.y.254 24
x can be any number in the range 16-31. y can be any number in the range 0-255.
A valid private IP address could be 192.168.1.1. A valid FQDN for this IP could be lfs.example.org.
Even if not using a network card, a valid FQDN is still required. This is necessary for certain programs to operate correctly.
/etc/hosts file by
cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version) 127.0.0.1 localhost ::1 localhostEOF
[alias1] [alias2] ...# End /etc/hosts (network card version)
need to be changed for specific uses or requirements (if assigned
an IP address by a network/system administrator and the machine
will be connected to an existing network). The optional alias
name(s) can be omitted.
If a network card is not going to be configured, create the
/etc/hosts file by running:
cat > /etc/hosts << "EOF"
# Begin /etc/hosts (no network card version) 127.0.0.1EOF
<HOSTNAME>localhost ::1 localhost # End /etc/hosts (no network card version)
The ::1 entry is the IPv6 counterpart of 127.0.0.1 and represents the IPv6 loopback interface.