Table of Contents

Network Configuration

This article is about network configuration in GNU/Linux systems

ifupdown

Dynamic configurations

Dynamic configuration with ifupdown (IPv4)

# /etc/network/interfaces
iface ens3 inet dhcp

Dynamic configuration with ifupdwon (IPv6)

iface ens3 inet6 auto

Static configurations

Static configuration with ifupdown (IPv4)

# /etc/network/interfaces

iface ens3 inet static
    address 10.0.1.115
    netmask 255.255.0.0
    gateway 10.0.0.1
    dns-nameservers 1.1.1.1 8.8.8.8
    dns-search example.com

Static configuration with ifupdown (IPv6)

iface ens3 inet6 static
    address 2001:db8:1234::10
    netmask 64
    gateway 2001:db8:1234::1
    dns-nameservers 2606:4700:4700::1111 2001:4860:4860::8888

Adding extra routes with ifupdown (up and down run shell commands)

iface ens3 inet static
    address 10.0.1.115
    netmask 255.255.0.0
    up ip route add 192.168.100.0/24 via 10.0.0.2
    down ip route del 192.168.100.0/24 via 10.0.2

systemd-networkd

[Match]
Name=ens3

[Network]
Address=10.0.1.115/16
Gateway=10.0.0.1
DNS=1.1.1.1
DNS=8.8.8.8

Address=2001:db8:1234::10/64
Gateway=2001:db8:1234::1
DNS=2606:4700:4700::1111
IPv6AcceptRA=no

[Route]
Destination=192.168.100.0/24
Gateway=10.0.0.2

Mapping