ip Command
The ip command is a modern and powerful tool for network configuration on Linux. It replaces older, classic tools like ifconfig, route, and arp.
Managing IP Addresses
Show All Interfaces
ip addr showDisplays information about all network interfaces on the system. Can be shortened to ip a.
Show Specific Interface
ip addr show eth0Shows information only for a specific interface (e.g., eth0).
Assign Static IP
ip addr add 192.168.1.100/24 dev eth0Assigns a static IP address and a subnet mask to an interface.
Remove IP
ip addr del 192.168.1.100/24 dev eth0Removes an IP address from an interface.
Managing Routing Table
Show Routing Table
ip route showDisplays the kernel routing table. Can be shortened to ip r.
Set Default Gateway
ip route add default via 192.168.1.1Sets the default gateway for all traffic, which is the router traffic is sent to by default.
Checking Your Public IP Address
Your local IP address is different from your public (external) IP address, which is visible on the internet. You can find your public IP by querying an external web service.
Get Public IPv4
curl ifconfig.meRetrieves and displays your public IPv4 address from the ifconfig.me service.
Get Public IPv6
curl -6 ifconfig.meForces curl to use IPv6 to retrieve and display your public IPv6 address (if available).