11.3 Command-line Network Configuration Interfaces

If the NetworkManager service is running, you can use the nm-tool command to display a verbose listing of the state of the system's physical network interfaces, for example:

# nm-tool

NetworkManager Tool

State: connected

- Device: eth0  [System eth0] --------------------------------------------------
  Type:              Wired
  Driver:            e1000
  State:             connected
  Default:           yes
  HW Address:        08:00:27:16:C3:33

  Capabilities:
    Carrier Detect:  yes
    Speed:           1000 Mb/s

  Wired Properties
    Carrier:         on

  IPv4 Settings:
    Address:         10.0.2.15
    Prefix:          24 (255.255.255.0)
    Gateway:         10.0.2.2

    DNS:             192.168.249.52
    DNS:             192.168.249.41

You can also use the ip command to display the status of an interface, for debugging, or for system tuning. For example, to display the status of all active interfaces:

# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:16:c3:33 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
    inet6 fe80::a00:27ff:fe16:c333/64 scope link 
       valid_lft forever preferred_lft forever

For each network interface, the output shows the current IP address, and the status of the interface. To display the status of a single interface such as eth0, specify its name as shown here:

# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:16:c3:33 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
    inet6 fe80::a00:27ff:fe16:c333/64 scope link 
       valid_lft forever preferred_lft forever

You can also use ip to set properties and activate a network interface. The following example sets the IP address of the eth1 interface and activates it:

# ip addr add 10.1.1.1/24 dev eth1
# ip link set eth1 up
Note

You might be used to using the ifconfig command to perform these operations. However, ifconfig is considered obsolete and will eventually be replaced altogether by the ip command.

Any settings that you configure for network interfaces using ip do not persist across system reboots. To make the changes permanent, set the properties in the /etc/sysconfig/network-scripts/ifcfg-interface file.

Any changes that you make to an interface file in /etc/sysconfig/network-scripts do not take effect until you restart the network service or bring the interface down and back up again. For example, to restart the network service:

# service network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated
                                                           [  OK  ]

To restart an individual interface, you can use the ifup or ifdown commands, which invoke the script in /etc/sysconfig/network-scripts that corresponds to the interface type, for example:

# ifdown eth0
Device state: 3 (disconnected)
# ifup eth0
Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated

Alternatively, you can use the ip command:

# ip link set eth0 down
# ip link set eth0 up

The ethtool utility is useful for diagnosing potentially mismatched settings that affect performance, and allows you to query and set the low-level properties of a network device. Any changes that you make using ethtool do not persist across a reboot. To make the changes permanent, modify the settings in the device's ifcfg-interface file in /etc/sysconfig/network-scripts.

For more information, see the ethtool(8), ifup(8), ip(8), and nm-tool(1) manual pages.