Static IP configuration in Debian 12

To configure a static on a Debian 12 server, open up the /etc/network/interfaces file and configure it like the example below.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp1s0
iface enp1s0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 9.9.9.11
# This is an autoconfigured IPv6 interface
iface enp1s0 inet6 static
address fd00::2
netmask 64
autoconf 1 #this will allow the networking module to procure a global IPv6 address from the local DHCPv6 server, or the router advertisement.
dns-nameservers 2620:fe::11

After this change, you’ll need to restart the corresponding unit. Issue this command:

systemctl restart networking.service

Be aware, that active SSH connections will be disrupted.