Linux networking
0 of 36 nailed
Linux30
ip -br addr- Lists every interface on one line with its operational state and all IPv4 and IPv6 addresses, including secondaries that ifconfig hides.
Example
Output lo UNKNOWN 127.0.0.1/8 ::1/128 ens192 UP 10.0.10.21/24 fe80::250:56ff:fea1:2b3c/64 ip -s link show dev ens192- Shows link flags, MTU and the RX and TX counters for packets, bytes, errors and drops. Run it twice to see which counters move.
ip route get 198.51.100.80- Asks the kernel for the real lookup result, through policy rules and all tables, with next hop, output interface, source address and any cached path MTU.
Example
Output 198.51.100.80 via 10.0.10.1 dev ens192 src 10.0.10.21 uid 1000 cache ip route show table all- Prints the routes of every table, including local and any policy routing tables that plain ip route hides.
ip rule show- Lists the policy routing rules in priority order. The defaults are 0 lookup local, 32766 lookup main and 32767 lookup default.
ip neigh show dev ens192- Shows the ARP or NDP cache for one interface with each entry's state, such as REACHABLE, STALE, DELAY, FAILED or PERMANENT.
ip link add link ens192 name ens192.10 type vlan id 10- Creates an 802.1Q VLAN subinterface for VLAN 10 on ens192. Put the address on ens192.10 and bring both interfaces up.
ip link add br0 type bridge vlan_filtering 1- Creates a VLAN-aware Linux bridge. Ports are added with ip link set <dev> master br0 and VLANs with bridge vlan add.
bridge vlan show- Lists each bridge port's VLAN membership, marking the PVID and which VLANs leave untagged.
bridge fdb show br br0- Shows the bridge's MAC address table, with the port each MAC was learned on.
cat /proc/net/bonding/bond0- Shows the bond mode, hash policy, link monitoring, LACP partner and aggregator, and each slave's state and failure count.
ip netns exec red ip -br addr- Runs a command inside the red network namespace. ip -n red is the short form for ip commands.
ip link add veth-red type veth peer name veth-red-br- Creates a veth pair, two connected virtual interfaces. Move one end into a namespace with ip link set veth-red netns red.
ss -tulpn- Lists listening TCP and UDP sockets with numeric addresses and the owning process. Run as root to see every process.
ss -tni state established '( dport = :443 or sport = :443 )'- Shows established HTTPS connections with TCP internals per flow, such as RTT, RTO, cwnd, MSS and retransmissions.
tcpdump -i ens192 -nn -e 'arp or icmp'- Captures ARP and ICMP with MAC addresses and VLAN tags shown, without name or port lookups. The first capture for most reachability problems.
tcpdump -i ens192 -nn -c 5000 -w /tmp/web.pcap 'host 198.51.100.80 and port 443'- Saves up to 5000 packets of one conversation to a pcap file for Wireshark. Read it back with tcpdump -nn -r /tmp/web.pcap.
dig @10.0.20.53 app.corp.example.com- Queries one DNS server directly, bypassing resolv.conf, and shows the status code, flags, answer records with TTLs and the server that replied.
resolvectl status- Shows systemd-resolved's real upstream DNS servers and search domains per interface, and whether /etc/resolv.conf is its stub file.
getent hosts app.corp.example.com- Resolves a name through NSS exactly as applications do, including /etc/hosts. Use it when dig and the application disagree.
curl -sv -o /dev/null https://app.example.com/health- Shows the DNS result, TCP connect, TLS details, request headers and response status for one request, discarding the body.
ping -M do -s 1472 -c 3 10.0.10.1- Sends 1500-byte packets with DF set to test the path MTU. A router answering Frag needed reports the smaller MTU.
sysctl net.ipv4.ip_forward net.ipv4.conf.all.rp_filter- Shows whether IPv4 forwarding is on and the global reverse path filter mode (0 off, 1 strict, 2 loose).
iptables -L -n -v --line-numbers- Lists the filter table's chains with policies, packet and byte counters per rule, and rule positions for inserting or deleting.
iptables -t nat -S- Prints the nat table as the commands that would recreate it, showing DNAT, SNAT and MASQUERADE rules that plain iptables -L hides.
nft list ruleset- Prints the whole nftables ruleset for every family, including rules added through iptables-nft.
conntrack -L -p tcp --dport 443- Lists tracked connections to port 443 with state, timeout and both tuples, which shows any NAT translation in the reply tuple.
ethtool ens192- Shows negotiated speed, duplex, autonegotiation and whether a link is detected. ethtool -S ens192 shows driver counters.
netplan try- Applies the netplan config and rolls it back after 120 seconds unless you confirm. The safe way to change networking over SSH.
nmcli device status- Lists interfaces with their NetworkManager state and active connection, showing which devices NetworkManager manages.