Skip to content

Set static IP | Network interface | debian

Bash
sudo nano /etc/network/interfaces
Text Only
# 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 ens18
#iface ens18 inet dhcp   # commented out
 
# add static settings  
iface ens18 inet static
# IP address
address 192.168.1.33
# network address
network 192.168.1.0
# subnet mask
netmask 255.255.255.0
# broadcast address 
broadcast 192.168.1.255
# default gateway  
gateway 192.168.1.1 
# name server
dns-nameservers 1.1.1.1 

ens18 - example interface

Restart

Bash
systemctl restart ifup@ens18

Nameserver

Bash
systemctl status resolvconf.service NetworkManager.service

Unit resolvconf.service could not be found. Unit NetworkManager.service could not be found.

Bash
sudo nano /etc/resolv.conf
Bash
nameserver 1.1.1.1

Disable IPv6

  • as root
Bash
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
Bash
sysctl -p

Check with:

Bash
ip a