ipShow and change interfaces, addresses and routes
ip is the modern tool for the kernel's network configuration: interfaces (ip link), IP addresses (ip addr), the routing table (ip route) and ARP neighbours (ip neigh). Use it to answer 'what's my IP?', 'which way does traffic leave?' and to make temporary changes.
ip [-br] [-s] [-4|-6] OBJECT { show | add | del | set | get } ... (OBJECT: link addr route neigh)You're on an unfamiliar cloud VM and need its private IP, interface name and MTU.
sudoShowing is allowed for everyone; changing interfaces, addresses or routes needs root (CAP_NET_ADMIN).
ip sends rtnetlink messages to the kernel (RTM_GETLINK, RTM_GETADDR, RTM_GETROUTE to read; RTM_NEWADDR, RTM_NEWROUTE and friends to change) and prints the replies. Nothing is read from or written to files: changes take effect immediately and vanish at reboot, or sooner when systemd-networkd or NetworkManager reapplies their configuration (netplan on Ubuntu, NetworkManager on RHEL). For a packet, the kernel picks the route with the longest matching prefix (a /32 beats a /24 beats the 0.0.0.0/0 default), then the lowest metric; ip route get runs that exact lookup and shows the outgoing interface, next hop and source address. ip neigh shows the ARP cache that maps next-hop IPs to MAC addresses on the local link. ip link shows layer-2 state: UP means administratively enabled, LOWER_UP means the link (cable or virtual NIC) is actually connected. It replaces ifconfig, route and arp from the deprecated net-tools.
ip a / ip addr show [dev X]Addresses on all (or one) interfaceip -br a / ip -br linkBrief one-line-per-interface viewip r / ip routeRouting table (main)ip route get ADDRWhich route, interface and source IP a packet to ADDR would useip -s link show XInterface counters: bytes, packets, errors, dropsip link set X up|down|mtu NEnable, disable or change MTU of an interfaceip addr add|del IP/N dev XAdd or remove an address (until reboot)ip route add|del NET via GWAdd or remove a routeip neighARP/NDP neighbour cache: IP to MAC, and its state-4 / -6Only IPv4 or IPv6-cColour output-jJSON output, for scripts (ip -j a | jq ...)ip netnsNetwork namespaces (how containers get their own stack)Changing addresses or routes with ip and expecting them to survive a rebootip only edits the running kernel state; netplan/systemd-networkd or NetworkManager rebuild it from their config at boot (and sometimes at DHCP renewal).
Put the change in /etc/netplan/*.yaml (Ubuntu) or nmcli (RHEL), then applysudo ip link set ens5 down over SSH to 'bounce' the interfaceYour session goes through that interface, and taking it down also removes its routes, so the up command never arrives.
Use the console, or one line: sudo ip link set ens5 down && sudo ip link set ens5 up (still risky)ip route add ... in a provisioning scriptRe-running the script fails with 'RTNETLINK answers: File exists'.
ip route replace 10.20.0.0/16 via 10.0.1.1Reading 'state UNKNOWN' on lo as a problemLoopback and some virtual interfaces have no carrier concept; UNKNOWN is normal for them.
Check the flags: UP and LOWER_UP mean the interface works.Try these on a Linux machine of your own. Each task has a hint and a solution.
Show every interface in this sandbox with its state and addresses, one line each.
Show the routing table, then ask the kernel which route it would use to reach 8.8.8.8.
Try to add the address 192.0.2.10/32 to lo without sudo, read the error, then add it with sudo and confirm.
Print the receive and transmit counters of the loopback interface in human-readable form.
ipShow and change interfaces, addresses and routes
ip is the modern tool for the kernel's network configuration: interfaces (ip link), IP addresses (ip addr), the routing table (ip route) and ARP neighbours (ip neigh). Use it to answer 'what's my IP?', 'which way does traffic leave?' and to make temporary changes.
ip [-br] [-s] [-4|-6] OBJECT { show | add | del | set | get } ... (OBJECT: link addr route neigh)You're on an unfamiliar cloud VM and need its private IP, interface name and MTU.
sudoShowing is allowed for everyone; changing interfaces, addresses or routes needs root (CAP_NET_ADMIN).
ip sends rtnetlink messages to the kernel (RTM_GETLINK, RTM_GETADDR, RTM_GETROUTE to read; RTM_NEWADDR, RTM_NEWROUTE and friends to change) and prints the replies. Nothing is read from or written to files: changes take effect immediately and vanish at reboot, or sooner when systemd-networkd or NetworkManager reapplies their configuration (netplan on Ubuntu, NetworkManager on RHEL). For a packet, the kernel picks the route with the longest matching prefix (a /32 beats a /24 beats the 0.0.0.0/0 default), then the lowest metric; ip route get runs that exact lookup and shows the outgoing interface, next hop and source address. ip neigh shows the ARP cache that maps next-hop IPs to MAC addresses on the local link. ip link shows layer-2 state: UP means administratively enabled, LOWER_UP means the link (cable or virtual NIC) is actually connected. It replaces ifconfig, route and arp from the deprecated net-tools.
ip a / ip addr show [dev X]Addresses on all (or one) interfaceip -br a / ip -br linkBrief one-line-per-interface viewip r / ip routeRouting table (main)ip route get ADDRWhich route, interface and source IP a packet to ADDR would useip -s link show XInterface counters: bytes, packets, errors, dropsip link set X up|down|mtu NEnable, disable or change MTU of an interfaceip addr add|del IP/N dev XAdd or remove an address (until reboot)ip route add|del NET via GWAdd or remove a routeip neighARP/NDP neighbour cache: IP to MAC, and its state-4 / -6Only IPv4 or IPv6-cColour output-jJSON output, for scripts (ip -j a | jq ...)ip netnsNetwork namespaces (how containers get their own stack)Changing addresses or routes with ip and expecting them to survive a rebootip only edits the running kernel state; netplan/systemd-networkd or NetworkManager rebuild it from their config at boot (and sometimes at DHCP renewal).
Put the change in /etc/netplan/*.yaml (Ubuntu) or nmcli (RHEL), then applysudo ip link set ens5 down over SSH to 'bounce' the interfaceYour session goes through that interface, and taking it down also removes its routes, so the up command never arrives.
Use the console, or one line: sudo ip link set ens5 down && sudo ip link set ens5 up (still risky)ip route add ... in a provisioning scriptRe-running the script fails with 'RTNETLINK answers: File exists'.
ip route replace 10.20.0.0/16 via 10.0.1.1Reading 'state UNKNOWN' on lo as a problemLoopback and some virtual interfaces have no carrier concept; UNKNOWN is normal for them.
Check the flags: UP and LOWER_UP mean the interface works.Try these on a Linux machine of your own. Each task has a hint and a solution.
Show every interface in this sandbox with its state and addresses, one line each.
Show the routing table, then ask the kernel which route it would use to reach 8.8.8.8.
Try to add the address 192.0.2.10/32 to lo without sudo, read the error, then add it with sudo and confirm.
Print the receive and transmit counters of the loopback interface in human-readable form.