# Linux Networking Commands
## ip Command - Interface and Address Management
The ip command is the primary tool for network configuration on modern Linux systems.
ip addr show - displays all network interfaces with their IP addresses
ip addr show eth0 - shows only the eth0 interface
ip addr add 192.168.1.100/24 dev eth0 - adds an IP address to an interface
ip addr del 192.168.1.100/24 dev eth0 - removes an IP address from an interface
ip link show - shows link layer information for all interfaces
ip link set eth0 up - brings an interface up
ip link set eth0 down - brings an interface down
## ip Command - Routing
ip route show - displays the routing table
ip route add 192.168.2.0/24 via 192.168.1.1 - adds a static route
ip route del 192.168.2.0/24 - removes a route
ip route add default via 192.168.1.254 - adds a default gateway
## ping Command
ping 192.168.1.1 - pings an IP address continuously
ping -c 4 192.168.1.1 - sends exactly 4 ping packets
ping -i 2 192.168.1.1 - sends pings every 2 seconds
ping -s 1400 192.168.1.1 - sends pings with 1400 byte payload
ping6 2001:db8::1 - pings an IPv6 address
## traceroute Command
traceroute 8.8.8.8 - traces the route to Google DNS
traceroute -n 8.8.8.8 - does not resolve hostnames, faster output
traceroute -T 8.8.8.8 - uses TCP instead of UDP for probes
## netstat and ss Commands
netstat -tlnp - shows listening TCP ports with process names
netstat -tulnp - shows listening TCP and UDP ports
ss -tlnp - modern replacement for netstat shows listening TCP ports
ss -s - shows summary statistics
ss -o state established - shows established connections
## nslookup and dig Commands
nslookup google.com - resolves a domain name
nslookup -type=mx gmail.com - looks up mail exchange records
dig google.com - detailed DNS lookup
dig google.com A - looks up A record specifically
dig @8.8.8.8 google.com - queries a specific DNS server
dig google.com +short - returns only the IP address
## tcpdump Command
tcpdump -i eth0 - captures all packets on eth0
tcpdump -i eth0 host 192.168.1.1 - captures packets to or from that host
tcpdump -i eth0 port 80 - captures HTTP traffic
tcpdump -i eth0 -w capture.pcap - saves packets to a file
tcpdump -r capture.pcap - reads and displays saved capture file
tcpdump -i eth0 tcp and port 443 - captures HTTPS traffic
## arp Command
arp -a - shows the ARP cache
arp -d 192.168.1.1 - deletes an ARP entry
arp -s 192.168.1.1 aa:bb:cc:dd:ee:ff - adds a static ARP entry
## Other Useful Commands
hostname - shows the computer hostname
ifconfig - older interface configuration command
curl -I https://example.com - fetches HTTP headers only
wget https://example.com/file - downloads a file
nc -zv 192.168.1.1 80 - tests if port 80 is open on a host
nmap 192.168.1.0/24 - scans a network for live hosts and open portsBack to Course