<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-systemd-network">
  <?dbhtml filename="systemd-network.html"?>

  <title>Networking Configuration with Systemd-networkd</title>

  <sect2 role="static">
    <title>Creating the Static Network Interface Configuration Files</title>

    <note><para>Udev may assign random Network Card Interface names
    for some network cards such as enp2s1. If you are not sure what
    your Network Card Interface name is, you can always run
    <command>ip l</command> after you have booted your system. It is important that the <envar>Name</envar> variable in  <filename>/etc/systemd/network</filename> contain the correct Network Card Interface name (e.g.
    <envar>Name=enp2s1</envar> or
    <envar>Name=eth0</envar>) or Systemd will fail to bring
    up your network interface.</para></note>

    <para><command>systemd-networkd</command> uses <filename>/etc/system/network</filename> for configuration files. Refer to systemd.network(5) and systemd.netdev(5). Configure a network interface with a config file. Adjust Name= as required:</para>

<screen><userinput>cd /etc/systemd/network &amp;&amp;
cat &gt; static.network &lt;&lt; "EOF"
[Match]
Name=enp2s0

[Network]
Address=192.168.1.1/24
Gateway=192.168.1.2
EOF</userinput></screen>

    <para os="var-ob">The values of these variables must be changed in every
    file to match the proper setup.</para>

    <para os="var-i">The <envar>Name</envar> variable defines the interface
    name, for example, eth0. It is required for all network device configuration
    files.</para>

    <para>The <envar>Gateway</envar> variable should contain the default
    gateway IP address, if one is present. If not, then comment out the
    variable entirely.</para>

    <para>For more information see the <command>systemd.netdev</command> man page.</para>

  </sect2>

  <sect2 role="dhcp">
    <title>Connecting to a network with DHCP</title>

  <para><command>systemd-networkd</command> uses <filename>/etc/systemd/network</filename> for configuration files. Refer to <filename>systemd.network(5)</filename> and <filename>systemd.netdev(5)</filename>. Configure a network interface with a config file. Adjust Name= as required:</para>

<screen><userinput>cd /etc/systemd/network &amp;&amp;
cat &gt; dhcp.network &lt;&lt; "EOF"
[Match]
Name=enp2s0

[Network]
DHCP=yes
EOF</userinput></screen>

  <para><command>systemd-networkd</command> will automatically configure <filename>/run/systemd/network/resolv.conf</filename> when using DHCP. If you did not manually create <filename>/etc/resolv.conf</filename>, create a symlink:</para>

<screen><userinput>ln -sv /run/systemd/network/resolv.conf /etc</userinput></screen>

  </sect2>

</sect1>
