Network Configuration on Raspberry Pi OS

Raspberry Pi Network Commands

Basic Network Information

  • ip addr — Displays IP addresses, MAC addresses, and network interface status.
  • route or ip route — Shows the paths packets take to reach network destinations.
  • cat /etc/resolv.conf — Lists the DNS servers your Pi is using.
  • hostname — Shows the current hostname.
  • hostname -I — Displays the Pi’s IP address(es).

Network Connectivity Testing

  • ping 8.8.8.8 — Checks if the internet or a specific IP is reachable.
  • traceroute google.com — Shows the path data packets take to reach a host.
  • nc -zv IP PORT — Checks if a port is open on a device.

Wi-Fi Management

  • sudo iwlist wlan0 scan — Lists available Wi-Fi networks.
  • Connect to Wi-Fi from CLI: Edit /etc/wpa_supplicant/wpa_supplicant.conf and add:
network={
  ssid="YourSSID"
  psk="YourPassword"
}
  
  • Restart Wi-Fi: sudo wpa_cli -i wlan0 reconfigure
  • iwconfig — Shows wireless network interface details, signal strength, and channel.

IP Configuration

  • sudo dhclient -r wlan0 and sudo dhclient wlan0 — Releases and renews DHCP lease.
  • Set static IP (example for eth0): Edit /etc/dhcpcd.conf:
interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
  
  • sudo ip link set dev eth0 mtu 9000 — Useful for high-speed networks; check compatibility.

Monitoring & Troubleshooting

  • ifstat, vnstat, or nload — Real-time bandwidth usage per interface.
  • netstat -tuln — Lists listening TCP/UDP ports.
  • ss -tuln — Modern replacement for netstat.
  • iperf3 -s (server) / iperf3 -c SERVER_IP (client) — Test network speed.
  • arp -a — Shows mapped IP addresses and MAC addresses in local network.

SSH & Remote Access

  • sudo systemctl enable ssh and sudo systemctl start ssh — Enable SSH.
  • ssh pi@192.168.1.20 — Connects to another device on the network.
  • scp localfile pi@192.168.1.20:/home/pi/ — Secure file copy via SSH.

Network Debugging

  • ip route get 8.8.8.8 — Display routing for specific host.
  • ifconfig wlan0 or cat /sys/class/net/wlan0/statistics/rx_errors — Check interface statistics/errors.
  • ping -M do -s 8972 192.168.1.1 — Useful for MTU testing.
  • Advanced tools: tcpdump, wireshark, or nmap — For deeper network analysis.

H Santhosh Nagraj

I’m an IT professional passionate about Linux, sharing tips and insights to help you optimize and manage Linux systems effectively.

Previous Post Next Post

Contact Form