Linux Networking


The generic section will cover networking utilities that are platform agnostic.


The systemd init suite provides both “systemd-networkd” and systemd-resolved” to control networking devices. These services have been included in systemd since version 210. [1]

All systemd network settings should be configured in the directory “/etc/systemd/network/.” Network files should have the “.network” extension and NetDev files will use “.netdev.” Common options are listed below. [2][3]

Network Settings:

  • [Match] = Select the device to use.

    • Name = The device name.

    • MACAddress = The MAC address for the device.

  • [Network] = Network settings.

    • DHCP = Use DHCP.

      • yes, no, ipv4, or ipv6

    • DHCPServer = Become a DHCP server.

      • yes, no

    • Address = The IP address to use on the interface.

    • Gateway = The default gateway.

    • DNS = A list of DNS servers.

    • NTP = A list of NTP servers.

    • IPForward = Allow IP addresses to be routed based on the netfilter routing table.

      • yes, no, ipv4, ipv6

    • IPMasquerade = Allow IPv4 addresses to be set up for source network address translation (SNAT).

      • yes, no, ipv4

    • Bond = The name of the bond interface to use.

    • VLAN = The name of the VLAN interface to use.

    • VXLAN = The name of the VXLAN interface to use.

    • Tunnel = The name of the tunnel interface to use.

  • [Link]

    • MACAddress = Override the MAC address with a custom address.

    • MTUBytes = The MTU size for packets.

  • [DHCPServer] = Configure DHCP server settings.

    • PoolOffset = The offset count (not including network or broadcast addresses) to start the IP allocation pool from.

    • PoolSize = The number of IP addresses that can be allocated.

    • DNS = A list of DNS servers to provide.

    • EmitRouter = The default gateway to provide.

    • NTP = The NTP server to provide.

    • Timezone = The timezone to provide. [2]

NetDev settings:

  • [NetDev] = Virtual network devices.

    • Name = Create a name for the device.

    • MACAddress = Create a MAC address for the device. A randomly generated address will be created if this option is not specified.

    • MTUBytes = The MTU size for packets.

    • Kind = The type of virtual network device.

      • bond = A combination of multiple NICs.

      • bridge = Allow guests to have full passthrough access to the NIC.

      • dummy = Drop all packets.

      • gretap = GRE layer 2 tunnel.

      • gre = GRE layer 3 tunnel.

      • tap = Layer 2 tunnel.

      • tun = Layer 3 tunnel.

      • vlan = VLAN tagging.

      • vxlan = VXLAN tunnel.

  • [Bond]

    • Mode = The bond mode to use for clustering NICs.

      • balance-rr

      • active-backup

      • balance-xor

      • broadcast

      • 802.3ad

      • balance-tlb

      • balance-alb

  • [Tunnel] = Tunnel configurations

    • Local = The static IP address that should already be configured on another NIC. This is used to connect to the remote tunnel IP address.

    • Remote = The remote IP address to create a tunnel connection between.

  • [VLAN]

    • Id = The VLAN ID.

  • [VLAN]

    • Id = The VXLAN ID. [3]

Static networking syntax:



Static networking example:




A Network configuration can be created for a Wi-Fi interface. Using the “wpa_supplicant” service, the Wi-Fi password can be securely saved in a different file and will automatically be used by systemd-network.

Wi-Fi syntax:

$ sudo wpa_passphrase <SSID> <PASSWORD> > /etc/wpa_supplicant/wpa_supplicant-<NIC>.conf
$ sudo systemctl enable wpa_supplicant@<NIC>.conf
$ sudo systemctl start wpa_supplicant@<NIC>.conf

Wi-Fi example:

$ sudo wpa_passphrase Guest5G password123 > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
$ sudo systemctl enable wpa_supplicant@wlan0.conf
$ sudo systemctl start wpa_supplicant@wlan0.conf


Open vSwitch


Any physical network interface can be turned into a bridge. This allows multiple devices to be able to utilize the bridge for straight connectivity to the physical network. In this example, eth0 is converted into the br0 bridge.


$ sudo ovs-vsctl add-br br0
$ sudo ovs-vsctl add-port br0 eth0


$ sudo ovs-vsctl add-br <NEW_BRIDGE>
$ sudo ovs-vsctl add-port <NEW_BRIDGE> <PHYSICAL_INTERFACE>

It is possible to create multiple bridges from one physical interface. This official example from the Open vSwitch documentation shows how to use the physical interface eth0 to create the virtual bridges br0 and br1. Patch ports are used to connect the tap interfaces.


$ sudo ovs-vsctl add-br br0
$ sudo ovs-vsctl add-port br0 eth0
$ sudo ovs-vsctl add-port br0 tap0
$ sudo ovs-vsctl add-br br1
$ sudo ovs-vsctl add-port br1 tap1
$ sudo ovs-vsctl \
       -- add-port br0 patch0 \
       -- set interface patch0 type=patch options:peer=patch1 \
       -- add-port br1 patch1 \
       -- set interface patch1 type=patch options:peer=patch0

Open vSwitch uses virtual tap interfaces to connect virtual machines to a bridge instead of providing straight access to a bridge device. This makes it easier to manage interfaces for many virtual machines and it helps to isolate and track down traffic. Tools such as tcpdump can be used to analyze specific tap traffic. [5]


$ sudo ovs-vsctl add-br br0
$ sudo ovs-vsctl add-port br0 eth0
$ sudo ovs-vsctl add-port br0 tap0
$ sudo ovs-vsctl add-port br0 tap1
$ sudo ovs-vsctl add-port br0 tap2


$ sudo ovs-vsctl add-br <NEW_BRIDGE>
$ sudo ovs-vsctl add-port <NEW_BRIDGE> <PHYSICAL_INTERFACE>
$ sudo ovs-vsctl add-port <NEW_BRIDGE> <NEW_TAP_INTERFACE>

Operating System Specific


The Debian network configuration file is located at /etc/networks/interfaces. Run ifup or ifdown to add or remove the IP address configurations for a particular interface

Static example:

File: /etc/network/interfaces

auto eth0
iface eth0 inet static
iface eth0 inet static
$ sudo ifup eth0

DHCP example:

File: /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
$ sudo ifup eth0


  • auto <INTERFACE> = Start the interface on boot.

  • iface <INTERFACE> inet {static|dhcp} = Specify if the IP address should be static or dynamic. Define this again for every IP address that will be used.

    • address = The IP address to add.

    • netmask = The subnet mask for the IP address.

    • gateway = The default gateway.

    • dns-nameservers = A list of DNS resolvers to use, separated by a space.



Syntax for /etc/network/interfaces:

iface <BRIDGE_NAME> inet static
  bridge_ports <PORT1> <PORT2>
  address <IP_ADDRESS>
  netmask <NETMASK>

Bridge options:

  • bridge_stp [on|off] = Turn the Spanning Tree Protocol (STP) on or off.

  • bridge_waitport <DELAY> = The number of seconds to delay before turning on the virtual interface.

  • bridge_fd <DELAY> = The number of seconds to delay before forwarding a packet.

  • bridge_ports <PORT1> <PORT2> = The ethernet port(s) to create a bridge on.

  • bridge_ports regex eth* = Define a regular expression of the the ethernet ports to create a bridge on.

Example of eth0 converted into a bridge br0 with a static IP address:

iface br0 inet static
  bridge_ports eth0
  bridge_stp on
  brdige_waitport 30
  bridge_fd 1



Red Hat Enterprise Linux uses their own “network” service. Although Network Manager has started taking it’s place, the network service is less intrusive and better supported by most programs that rely on managing network settings.

There are two udev modules that manage new device naming schemes: “net.ifnames” and “biosdevname.” Only “net.ifnames” is installed by default on RHEL. Set these both to 0 in the kernel/boot options to revert back to eth* and wlan* naming. Otherwise, devices will be named based on their physical location and connection to the motherboard. [7]

Network configurations are saved in /etc/sysconfig/network-scripts/. The Ethernet device names start with “ifcfg-eth” when ifnames is disabled or “ifcfg-e” if not.


  • {NAME|DEVICE} = The name of the network interface. The first device is generally “eth0” for Ethernet or “wlan0” for wireless devices.

  • ONBOOT = {yes|no}. Enable or disable this interface on startup of the system.

  • HWADDR = The MAC address of the device.

  • BOOTPROTO = The boot protocol to use for obtaining an IP address.

    • {none|static} = Static IP addressing. Do not use any protocol.

    • dhcp = Dynamic IP addressing. Use DHCP to obtain IP addressing information.

    • bootp = Dynamic IP addressing. Use BOOTP to obtain IP addressing information.

  • DHCP_HOSTNAME = If a DHCP server requires a hostname, specify the hostname for the system.

  • DHCPV6C = {yes|no}. Enable or disable the ability to obtain an IPv6 address via DHCP.

  • DHCPV6C = Specify DHCP options for IPv6.

    • -P = Prefix delegation.

    • -S = Obtain a stateless address.

    • -N = Revert to normal operation after using -P or -T.

    • -T = Temporarily obtain an IPv6 address.

    • -D = Specify a new value for the DHCP Unique Identifier (DUID).

  • IPV6_AUTOCONF = {yes|no}. Enable or disable autoconf configuration.

  • DNS{1,2} = The DNS nameservers to use for /etc/resolv.conf.

  • PEERDNS = {yes|no}. Enable or disable the ability to get DNS information for /etc/resolv.conf from DHCP or IPCP.

  • ETHTOOL_OPTS = Provide special ethtool options for the interface.

  • IPADDR = An IPv4 address. This option’s name can have a number appended to it (starting at 0) to specify multiple IP addresses.

  • NETMASK = The IPv4 address’s netmask.

  • PREFIX = Instead of specifying a netmask, the CIDR prefix can be used.

  • GATEWAY = The IPv4 default gateway to use. All IPv4 traffic will route out to this IP.

  • MTU = The size of packets to use, in bytes. The default is 1500 and the maximum is 9000.

  • IPV6INIT = {yes|no}. Enable or disable IPv6 on this interface.

  • IPV6ADDR6 = An IPv6 address with it’s CIDR prefix.

  • IPV6ADDR_SECONDARIES = Other IPv6 addresses, comma separated, to add tot his interface.

  • IPV6_PRIVACY=rfc3041 = Use the RFC 3041 standard to create a stateless IPv6 address using the interface’s MAC address. By default, if this option is not defined, it is turned off for security concerns.

  • IP6MTU = The size of packets to use, in bytes.

  • MASTER = The master device for bonds.

  • BONDING_OPTS = Additional bonding driver options.

  • HOTPLUG = Default: yes. Activate his device if it is hot plugged into the system.

  • LINKDELAY = The number of seconds to wait before loading up the network interface’s configuration.

  • SRCADDR = The primary source address for outgoing traffic.

  • USERCTL = Enable or disable the ability to allow non-privileged users to manage the interface.

  • NM_CONTROLLED = {yes|no}. Enable or disable Network Manager control over this interface.



In RHEL 7, static routes now use the iproute2 syntax. A new route-<INTERFACE> file defines the route. Only one default GATEWAY can be set in the original ifcfg- configuration files.


$ sudo vim /etc/sysconfig/network-scripts/route-<INTERFACE>


$ sudo vim /etc/sysconfig/network-scripts/route-eth0 via dev eth0



A simple bridge using the Linux kernel can be configured using this basic template. The physical network interface should reference a bridge interface. The bridge interface will then contain the IP addressing information.

File: ifcfg-<NIC>


File: ifcfg-<BRIDGE>



Open vSwitch

Various bridge configurations can be made. It is common to use a normal bridge for allow virtual machines to have full access to the network or use an Open vSwitch bridge for OpenStack’s software defined networking (SDN).

Open vSwitch bridge syntax (CLI):

$ sudo ovs-vsctl add-port <OVS_BRIDGE> <NIC>
$ sudo ovs-vsctl add-br <OVS_BRIDGE>


Open vSwitch bridge syntax (configuration file):

File: ifcfg-<NIC>


File: ifcfg-<OVS_BRIDGE>


Open vSwitch bridge example (configuration file):

File: ifcfg-eth1


File: ifcfg-br0-ovs




Bonding allows for multiple devices to be used as a single virtual device. The physical NICs need to be configured as bond slaves. Then a new bond configuration can be created for the bond device.

Bond master syntax:


Bond master example:


Bond slave syntax:


Bond slave example:



A full list of bonding driver options for “bonding_opts” can be found here:

Common bonding_opts options:

  • mode = The bonding method to use.

    • {0|balance-rr} = Load balance using round robin. Every other request goes to/from a different interface.

    • {1|active-backup} = Only one interface is used. If it fails, then a slave device will take over.

    • {2|balancer-xor} = Load balance requests based on the source and destination MAC addresses.

    • {3|broadcast} = All traffic is sent out through all of the network interfaces.

    • {4|802.3ad} = All of the network devices use the same speed and duplex configuration to follow the 802.3ad bonding standard. This requires that the network interfaces are also connected to a switch that supports the IEEE 802.3ad Link Aggregation Control Protocol (LACP) standard. The switch must have LACP enabled on the relevant ports.

    • {5|balance-tlb} = Adaptive transmit load balancing. Load balance outgoing requests based on the slave usage.

    • {6|balance-alb} = Adaptive load balancing. Load balance incoming and outgoing requests based on slave usage.




SSH keys are the most common way to authenticate to a UNIX-like server. A public and private key-pair are generated on the client side. For a successful authentication, the server knows of a public key and then a connecting client offers a private key that must go through an algorithm to see if it matches with the public key.

Secure algorithms:

  1. Ed25519 = The most secure.

  2. ECDSA

  3. RSA >= 4096-bit = The most widely supported format.

Insecure algorithms:

  • DSA

  • RSA < 4096-bit


Generate a new SSH key using the following command:

$ ssh-keygen -t <ALGORITHM> -b <BIT_SIZE>



Error when starting the sshd service and trying to connect to it via a remote host:

$ sudo journalctl -u ssh
Nov 15 00:12:09 systemd[1]: Starting OpenBSD Secure Shell server...
Nov 15 00:12:09 sshd[324]: Could not load host key: /etc/ssh/ssh_host_rsa_key
Nov 15 00:12:09 sshd[324]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Nov 15 00:12:09 sshd[324]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Nov 15 00:12:09 sshd[336]: Could not load host key: /etc/ssh/ssh_host_rsa_key
Nov 15 00:12:09 sshd[336]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Nov 15 00:12:09 sshd[336]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Nov 15 00:12:09 sshd[336]: Server listening on port 22.
Nov 15 00:12:09 sshd[336]: Server listening on :: port 22.
Nov 15 00:12:09 systemd[1]: Started OpenBSD Secure Shell server.
Nov 15 00:13:19 sshd[398]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Nov 15 00:13:19 sshd[398]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Nov 15 00:13:19 sshd[398]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Nov 15 00:13:19 sshd[398]: fatal: No supported key exchange algorithms [preauth]


  • Create the host key files on the sshd server [18]:

    $ sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
    $ sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
    $ sudo ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key


  1. “How to switch from NetworkManager to systemd-networkd on Linux.” Xmodulo. August 31, 2015. Accessed November 27, 2016.

  2. “ — Network configuration.” Accessed November 27, 2016.

  3. “systemd.netdev — Virtual Network Device configuration.” Accessed November 27, 2016.

  4. “Managing WPA wireless with systemd-networkd ?” Arch Linux Wiki - Networking, Server, and Protection. March 13, 2014. Accessed November 27, 2016.

  5. “Frequently Asked Questions Open vSwitch.” Open vSwitch Support. March 30, 2017. April 9, 2017.

  6. “[Ubuntu 16.04] Network Configuration.” Ubuntu Documentation. June 23, 2017. Accessed July 2, 2017.

  7. “Disable consistent network device naming in RHEL7.” Red Hat Community Discussions. June 11, 2014. Accessed January 7, 2016.

  8. “Interface Configuration Files.” Accessed January 7, 2016.

  9. “How to add a new static route on RHEL7 Linux.” Linux Config. March 17, 2015. Accessed April 9, 2017.

  10. “Static Routes and the Default Gateway.” Red Hat Documentation. March 15, 2017. Accessed April 9, 2017.

  11. “Network Bridge.” Red Hat Documentation. May 29, 2016. Accessed February 24, 2017.

  12. Configuring Libvirt guests with an Open vSwitch bridge.” Kashyap Chamarthy. July 13, 2013. Accessed November 27, 2016.

  13. “Configure Fedora Server with Open vSwitch and Libvirt.” GitHub Gist - jdoss. October 31, 2015. Accessed November 27, 2016.

  14. “RHEL: Linux Bond / Team Multiple Network Interfaces (NIC) Into a Single Interface.” nixCraft. March 27, 2016. Accessed January 7, 2016.

  15. “Bonding Interfaces.” CentOS Tips and Tricks. January 22, 2013. Accessed January 7, 2016.

  16. “Upgrade Your SSH Key to Ed25519.” RISAN A journal of a passionate coder. January 9, 2018. Accessed January 12, 2021.

  17. “Bridging Network Connections.” Debian Wiki. April 24, 2020. Accessed November 10, 2020.

  18. “sshd shuts down with “No supported key exchange algorithms” error.” August 8, 2019. Accessed November 14, 2020.