wiki:debian-networking
Table of Contents
Debian Networking
Configure and troubleshoot network interfaces, routing, and DNS on Debian.
Network Interfaces
Show interfaces and addresses:
ip addr show ip addr show eth0
Bring interface up/down:
sudo ip link set eth0 up sudo ip link set eth0 down
Assign IP address (temporary):
sudo ip addr add 192.168.1.100/24 dev eth0 sudo ip addr del 192.168.1.100/24 dev eth0
Routing
Show routing table:
ip route show
Add default gateway:
sudo ip route add default via 192.168.1.1
Add static route:
sudo ip route add 10.0.0.0/8 via 192.168.1.1
DNS
Show DNS servers:
cat /etc/resolv.conf
Set temporarily:
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
Persistent via /etc/network/interfaces:
auto eth0
iface eth0 inet dhcp
dns-nameservers 8.8.8.8 8.8.4.4
Or use NetworkManager (GUI preferred on desktop):
nmcli device show eth0
nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4"
Testing Connectivity
Ping a host:
ping -c 4 8.8.8.8
Trace route to host:
traceroute google.com
Test DNS:
nslookup google.com
dig google.com
Check open ports:
ss -tlnp # listening TCP ports ss -ulnp # listening UDP ports netstat -tlnp # old alternative
Hostname
Show current hostname:
hostname
Set permanently:
sudo hostnamectl set-hostname newname
Or edit directly:
sudo nano /etc/hostname sudo systemctl restart systemd-hostnamed
Static Configuration
Edit /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
Apply changes:
sudo systemctl restart networking
DHCP is simpler for most systems; use static only when necessary.
wiki/debian-networking.md · Last modified: by 127.0.0.1
