Raspberry Pi Network Commands
Basic Network Information
ip addr— Displays IP addresses, MAC addresses, and network interface status.routeorip 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.confand 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 wlan0andsudo 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, ornload— 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 sshandsudo 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 wlan0orcat /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, ornmap— For deeper network analysis.
Tags:
Raspberry Pi