Diagnostics, Routing, and Quick Setups
ip l : List all network interfaces (L2/MAC).ip l set eth0 up : Bring interface up.ip a : List all IP addresses.ip a add 192.168.1.10/24 dev eth0 : Assign temporary IPv4.ip r : Display IPv4 routing table.ip r add default via 192.168.1.1 : Set default gateway.ip n : Show ARP table (IPv4) / NDP table (IPv6).Run as root to see PIDs.
netstat -tuln : Show TCP/UDP Listening ports (Numbers only).netstat -tupan : Show active connections + Program/PID.netstat -rn : Display kernel routing table.ss -tuln : Modern, faster alternative to netstat.tcpdump -i eth0 : Capture all on eth0.tcpdump -i eth0 -n : Disable DNS resolution (faster).tcpdump -i eth0 port 80 : Filter by HTTP traffic.tcpdump -i eth0 host 10.0.0.5 : Filter by specific IP.tcpdump -i eth0 -vvv -X : Verbose, show HEX and ASCII.tcpdump -i eth0 -w cap.pcap : Write to file for Wireshark.ip -6 a : Show only IPv6 addresses.ip -6 r : Show IPv6 routing table.ip -6 addr add 2001:db8::1/64 dev eth0 : Assign static IPv6.ip -6 r add 2001:db8::1/64 via 2001:db8::1 dev eth0 : Assign static IPv6 Route.ip -6 neigh : View IPv6 neighbor cache (NDP).ping6 2001:db8::1 : Ping IPv6 address.sysctl -w net.ipv6.conf.all.forwarding=1 : Enable IPv6 routing.Connects interfaces at Layer 2.
# Create bridge & attach interfaces
ip link add name br0 type bridge
ip link set dev eth0 master br0
ip link set dev eth1 master br0
# Bring everything up
ip link set dev br0 up
ip link set dev eth0 up
ip link set dev eth1 up
Assuming eth0 is WAN and eth1 is LAN.
# Enable forwarding
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
# Set up Masquerading (NAT)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Fast temporary DHCP/DNS server on eth1.
# Listen on eth1, hand out .50 to .150
dnsmasq -d \
--interface=eth1 \
--dhcp-range=192.168.1.50,192.168.1.150,12h
1. Create /etc/hostapd/minimal.conf:
interface=wlan0
driver=nl80211
ssid=MyLinuxAP
hw_mode=g
channel=6
wpa=2
wpa_passphrase=SuperSecretPassword
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
2. Start the Access Point:
hostapd -d /etc/hostapd/minimal.conf