Skip to content
Search RunEntLinux

Searches general documentation on RunEntLinux. Each distribution has its own documentation search.

    Browse this documentation

    The ip command is the core of the iproute2 toolkit and the standard tool for managing network interfaces, IP addresses, and routes on modern Linux systems. This article covers how to use the ip command for network configuration on CentOS / AlmaLinux / Rocky Linux.

    List all network interfaces and their IP addresses
    ip addr show

    Short form:

    Short form for viewing IP addresses
    ip a

    Viewing the IP Address of a Specific Interface

    Section titled “Viewing the IP Address of a Specific Interface”
    View IP information for ens33 only
    ip addr show dev ens33
    Filter to show only IPv4 information
    ip -4 addr show
    Filter to show only IPv6 information
    ip -6 addr show
    Add a temporary IP address to ens33
    sudo ip addr add 192.168.1.200/24 dev ens33

    An interface can have multiple IP addresses bound to it:

    Add a second IP address
    sudo ip addr add 192.168.1.201/24 dev ens33
    Remove a temporarily added IP address
    sudo ip addr del 192.168.1.200/24 dev ens33
    List the link status of all network interfaces
    ip link show

    Short form:

    Short form for viewing link status
    ip l
    Bring up the ens33 interface
    sudo ip link set ens33 up
    Bring down the ens33 interface
    sudo ip link set ens33 down
    Set the MTU of ens33 to 9000 (jumbo frames)
    sudo ip link set ens33 mtu 9000
    Show packet transmit/receive statistics for an interface
    ip -s link show ens33
    Show the current routing table
    ip route show

    Short form:

    Short form for viewing the routing table
    ip r

    Example output:

    default via 192.168.1.1 dev ens33 proto dhcp metric 100
    192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.100 metric 100
    • default via 192.168.1.1 — Default gateway
    • 192.168.1.0/24 dev ens33 — Directly connected network

    Viewing the Route to a Specific Destination

    Section titled “Viewing the Route to a Specific Destination”
    Check which route is used to reach 8.8.8.8
    ip route get 8.8.8.8
    Remove the current default gateway
    sudo ip route del default
    Add a new default gateway
    sudo ip route add default via 192.168.1.254 dev ens33

    Permanently Setting the Default Gateway with nmcli

    Section titled “Permanently Setting the Default Gateway with nmcli”
    Permanently configure the default gateway
    sudo nmcli connection modify ens33 ipv4.gateway 192.168.1.1
    sudo nmcli connection up ens33
    Add a static route to the 10.10.0.0/16 network
    sudo ip route add 10.10.0.0/16 via 192.168.1.254 dev ens33
    Add a route to a specific host
    sudo ip route add 172.16.5.10/32 via 192.168.1.254
    Remove a static route
    sudo ip route del 10.10.0.0/16

    Permanently Adding Static Routes with nmcli

    Section titled “Permanently Adding Static Routes with nmcli”

    Temporary routes are lost after a reboot. Use nmcli to make them persistent:

    Add a permanent static route to a connection
    sudo nmcli connection modify ens33 +ipv4.routes "10.10.0.0/16 192.168.1.254"

    Adding multiple routes:

    Add multiple permanent static routes
    sudo nmcli connection modify ens33 \
    +ipv4.routes "10.10.0.0/16 192.168.1.254" \
    +ipv4.routes "172.16.0.0/12 192.168.1.253"

    Apply the configuration:

    Reactivate the connection to apply routes
    sudo nmcli connection up ens33
    View static routes configured in nmcli
    nmcli connection show ens33 | grep ipv4.routes
    Remove a permanent route
    sudo nmcli connection modify ens33 -ipv4.routes "10.10.0.0/16 192.168.1.254"
    sudo nmcli connection up ens33

    ifconfig belongs to the net-tools package and is no longer installed by default on newer EL systems. The ip command is more powerful and is the recommended replacement.

    Purposeifconfig (legacy)ip (modern)
    View all interfacesifconfigip addr show
    View a specific interfaceifconfig ens33ip addr show dev ens33
    Add an IP addressifconfig ens33 192.168.1.100 netmask 255.255.255.0ip addr add 192.168.1.100/24 dev ens33
    Bring up an interfaceifconfig ens33 upip link set ens33 up
    Bring down an interfaceifconfig ens33 downip link set ens33 down
    View the routing tableroute -nip route show
    Add a default gatewayroute add default gw 192.168.1.1ip route add default via 192.168.1.1
    View interface statisticsifconfig ens33ip -s link show ens33

    If you still need ifconfig, you can install net-tools:

    Install the net-tools package (provides ifconfig)
    sudo dnf install net-tools

    Output in JSON Format (convenient for script parsing)

    Section titled “Output in JSON Format (convenient for script parsing)”
    Output IP address information in JSON format
    ip -j addr show ens33

    Combined with jq for formatted output:

    Pretty-print JSON output with jq
    ip -j addr show ens33 | jq .
    Show IP addresses in brief mode
    ip -br addr show
    Show link status in brief mode
    ip -br link show
    Monitor route changes in real time
    ip monitor route
    Monitor all network events in real time
    ip monitor all
    Show the ARP neighbor cache
    ip neighbour show