Introduction

Configuring network components in linux can differ from distribution to distribution. I usually find myself searching for the information found here so this is part documentation for me and part blog post for anyone else who cares to read past the introduction.

This post covers various network related tasks on the following operating systems.

  • Centos 7
  • Ubuntu 1604
  • Cumulus 3.4.3

Interfaces

Configuration Files

Network interface configurations are stored in files in the following locations.

Operating System Location
Centos /etc/sysconfig/network-scripts/ifcfg-<ifname>
Ubuntu /etc/network/interfaces.d/<ifname>
Cumulus /etc/network/interfaces.d/<ifname>.intf

Apply Configuration

After interface configuration files are updated the network service needs to be reloaded for the configuration to be applied.

Operating System Location
Centos sudo systemctl restart network.service
Ubuntu sudo systemctl restart networking.service
Cumulus sudo systemctl restart networking.service

DHCP IP Address

DHCP v4/6 is used to automatically assign IP address and related information such as default gatway, search domains and DNS servers to a host.

Centos


# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=dhcp
ONBOOT=yes
PERSISTENT_DHCLIENT=yes
IPV6INIT=yes
DHCPV6C=yes
          

Ubuntu


# /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp
          

Cumulus


# /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 dhcp
          

Static IP Address

The following table defines static IPv4/6 configuration to be applied to the network interfaces.

IP Address Configuration

IPv4 IPv6
Address 10.1.1.10 fd00:4a26:d09b:d911::10
Network 10.1.1.0/24 fd00:4a26:d09b:d911::/64
Gateway 10.1.1.1 fd00:4a26:d09b:d911::1
DNS 8.8.8.8
8.8.4.4
2001:4860:4860::8888
2001:4860:4860::8844
Search Domain lab.local lab.local

Centos


# /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
NAME=eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.1.1.10
PREFIX=24
GATEWAY=10.1.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00:4a26:d09b:d911::10/64
IPV6_DEFAULTGW=fd00:4a26:d09b:d911::1
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
DOMAIN=lab.local
DNS1=8.8.8.8
DNS2=8.8.4.4
DNS3=2001:4860:4860::8888
DNS4=2001:4860:4860::8844
          

Ubuntu


# /etc/network/interfaces.d/eth1
auto eth1
iface eth1 inet static
    address 10.1.1.10
    netmask 255.255.255.0
    gateway 10.1.1.1
    dns-search lab.local
    dns-nameservers 8.8.8.8 8.8.4.4
iface eth1 inet6 static
    address fd00:4a26:d09b:d911::10/64
    gateway fd00:4a26:d09b:d911::1
    dns-search lab.local
    dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
          

Cumulus


# /etc/network/interfaces.d/swp1.intf
auto swp1
iface swp1 inet static
    address 10.1.1.10/24
    address fd00:4a26:d09b:d911::10/64
    gateway 10.1.1.1
    gateway fd00:4a26:d09b:d911::1
          

In Cumulus linux the nameserver and search domain properties are configured in the /etc/resolv.conf file.


# /etc/resolv.conf
search lab.local
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
            

Loopback Interface

Centos


# /etc/sysconfig/network-scripts/ifcfg-lo:1
NAME=lo:1
DEVICE=lo:1
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.1.1.10
PREFIX=24
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00:4a26:d09b:d911::10/64
IPV6_FAILURE_FATAL=no
          

Ubuntu


# /etc/network/interfaces.d/lo:1
auto lo:1
iface lo:1 inet static
    address 10.1.1.10
    mask 255.255.255.0
iface lo:1 inet6 static
    address fd00:4a26:d09b:d911::10/64
          

Cumulus

Loopback IP Addresses in Cumulus Linux should be configured in the /etc/network/interfaces file.


# /etc/network/interfaces
auto lo
iface lo inet loopback
    address 10.1.1.10/24
    address fd00:4a26:d09b:d911::10/64
          

VLAN L3 Interface

Centos

Load the 8021q kernel module.


sudo modprobe 8021q
          

# /etc/sysconfig/network-scripts/ifcfg-eth1:10
NAME=eth1.10
DEVICE=eth1.10
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.1.1.10
PREFIX=24
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00:4a26:d09b:d911::10/64
IPV6_FAILURE_FATAL=no
VLAN=yes
        

Ubuntu

Install vlan package to enable 802.1q.


sudo apt-get install vlan
          

Load the 8021q kernel module.


sudo modprobe 8021q
          

Create a parent interface configuration.


# /etc/network/interfaces.d/eth1
auto eth1
iface eth1 inet manual
        

VLAN Interface configuration


# /etc/network/interfaces.d/eth1.10
auto eth1.10
iface eth1.10 inet static
    vlan-raw-device eth1
    address 10.1.1.10
    netmask 255.255.255.0
iface eth1.10 inet6 static
    address fd00:4a26:d09b:d911::10/64
        

Cumulus

Cumulus Linux has the option of using a vlan-aware bridge which reduces the configuration required for large layer 2 networks. Note: Only one vlan-aware bridge is allowed per-switch.


# /etc/network/interfaces.d/bridge.intf
auto bridge
iface bridge
    bridge-ports swp1
    bridge-vids 10
    bridge-vlan-aware yes
        

# /etc/network/interfaces.d/vlan10.intf
auto vlan10
iface vlan10
    address 10.1.1.10/24
    address fd00:4a26:d09b:d911::10/64
    vlan-id 10
    vlan-raw-device bridge
        

Summary

Linux networking is a beast of a topic, there are many ways to do the same thing and many more ways when you compare how things are done in different distributions. This page is a bit of a living document and will be updated as I progress along the journey that is networking in Linux.

Links

https://docs.cumulusnetworks.com/display/DOCS/Interface+Configuration+and+Management






















Last Updated: 2017-12-13