# Debian Networking Configure and troubleshoot network interfaces, routing, and DNS on Debian. ## Network Interfaces Show interfaces and addresses: ```bash ip addr show ip addr show eth0 ``` Bring interface up/down: ```bash sudo ip link set eth0 up sudo ip link set eth0 down ``` Assign IP address (temporary): ```bash 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: ```bash ip route show ``` Add default gateway: ```bash sudo ip route add default via 192.168.1.1 ``` Add static route: ```bash sudo ip route add 10.0.0.0/8 via 192.168.1.1 ``` ## DNS Show DNS servers: ```bash cat /etc/resolv.conf ``` Set temporarily: ```bash 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): ```bash nmcli device show eth0 nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4" ``` ## Testing Connectivity Ping a host: ```bash ping -c 4 8.8.8.8 ``` Trace route to host: ```bash traceroute google.com ``` Test DNS: ```bash nslookup google.com dig google.com ``` Check open ports: ```bash ss -tlnp # listening TCP ports ss -ulnp # listening UDP ports netstat -tlnp # old alternative ``` ## Hostname Show current hostname: ```bash hostname ``` Set permanently: ```bash sudo hostnamectl set-hostname newname ``` Or edit directly: ```bash 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: ```bash sudo systemctl restart networking ``` DHCP is simpler for most systems; use static only when necessary.