Static IP configuration

Last change on 2024-06-12 • Created on 2020-07-02 • ID: CL-49F9C

Debian (ifup)

Edit /etc/network/interfaces:

auto eth0
iface eth0 inet static
        address <your IPv4 address>
        netmask 255.255.255.255
        gateway 172.31.1.1
        pointopoint 172.31.1.1
        dns-nameservers 185.12.64.1 185.12.64.2


iface eth0 inet6 static
        address <one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>
        netmask 64
        gateway fe80::1

Execute the following command

 rm /etc/network/interfaces.d/50-cloud-init.cfg

Ubuntu (netplan)

Edit /etc/netplan/50-cloud-init.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
      - <your IPv4 address>/32
      - <one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64
      routes:
      - to: 0.0.0.0/0
        via: 172.31.1.1
        on-link: true
      - to: default
        via: fe80::1
      match:
        macaddress: YOUR:MAC:ADDRESS
      set-name: eth0

Disable cloud-init network changes

Add file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg:

network:
  config: disabled

Edit /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection:

[connection]
id=cloud-init eth0
uuid=<keep the UUID as is!!>
type=ethernet

[ethernet]
mac-address=<keep the HWADDR as is!!>

[ipv4]
address1=<your IPv4 address>/32,172.31.1.1
dns=185.12.64.1;185.12.64.2;
may-fail=false
method=manual

[ipv6]
address1=<one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64,fe80::1
dns=2a01:4ff:ff00::add:1;2a01:4ff:ff00::add:2;
may-fail=false
method=manual

[proxy]

[user]
org.freedesktop.NetworkManager.origin=cloud-init

FreeBSD

Edit /etc/rc.conf

ifconfig_vtnet0="DHCP"
ifconfig_vtnet0_ipv6="inet6 <one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64"
ipv6_defaultrouter="fe80::1%vtnet0"

NetBSD

Edit /etc/rc.conf

dhcpcd=YES
dhcpcd_flags="-qM vioif0"
defaultroute6="fe80::1%vioif0"

Edit /etc/dhcpcd.conf

static ip6_address=<one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64
Table of Contents