The UniFi reservation method is often cleaner since it centralizes IP management and your Debian machine remains configured for DHCP.
Setting a Static IPv4 on Debian
Method 1: Using /etc/network/interfaces
- Edit the interfaces file:
sudo vi /etc/network/interfaces - Replace the DHCP configuration for your interface (commonly
eth0,enp0s3, or similar):
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 1.1.1.1 8.8.8.8- Then restart networking:
sudo systemctl restart networking
Method 2: Using NetworkManager (if installed)
nmcli con mod "Wired connection 1" \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "1.1.1.1,8.8.8.8" \
ipv4.method manual
nmcli con up "Wired connection 1"Switching Back to DHCP on Debian
Method 1: Using /etc/network/interfaces
- Edit the interfaces file:
sudo vi /etc/network/interfaces - Replace the static configuration with:
# The primary network interface
auto eth0
iface eth0 inet dhcp- Then restart networking:
sudo systemctl restart networking
Method 2: Using NetworkManager (if installed)
nmcli con mod "Wired connection 1" ipv4.method auto
nmcli con mod "Wired connection 1" ipv4.addresses ""
nmcli con mod "Wired connection 1" ipv4.gateway ""
nmcli con mod "Wired connection 1" ipv4.dns ""
nmcli con up "Wired connection 1"