Bookmark this page

Guided Exercise: Configuring Networking with nmcli

In this lab, you will configure network settings using nmcli.

Outcomes

Convert a system from DHCP to static configuration.

Reset your serverX system.

  1. View network settings using nmcli.

    1. Show all connections.

      [student@serverX ~]$ nmcli con show
      NAME         UUID                                  TYPE            DEVICE 
      System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0   
      
    2. Display all configuration settings for the active connection.

      [student@serverX ~]$ nmcli con show "System eth0"
      connection.id:                          System eth0
      connection.uuid:                        5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
      connection.interface-name:              eth0
      connection.type:                        802-3-ethernet
      connection.autoconnect:                 yes
      connection.timestamp:                   1394813303
      connection.read-only:                   no
      connection.permissions:                 
      ...
      IP4.ADDRESS[1]:                         ip = 172.25.X.11/24, gw = 172.25.X.254
      IP4.DNS[1]:                             172.25.254.254
      IP4.DOMAIN[1]:                          example.com
      ...
      
    3. Show device status.

      [student@serverX ~]$ nmcli dev status
      DEVICE  TYPE      STATE      CONNECTION  
      eth0    ethernet  connected  System eth0 
      lo      loopback  unmanaged  --          
      
    4. Display the settings for the eth0 device.

      [student@serverX ~]$ nmcli dev show eth0
      GENERAL.DEVICE:                         eth0
      GENERAL.TYPE:                           ethernet
      GENERAL.HWADDR:                         52:54:00:00:00:0B
      GENERAL.MTU:                            1500
      GENERAL.STATE:                          100 (connected)
      GENERAL.CONNECTION:                     System eth0
      GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
      WIRED-PROPERTIES.CARRIER:               on
      IP4.ADDRESS[1]:                         ip = 172.25.X.11/24, gw = 172.25.X.254
      IP4.DNS[1]:                             172.25.254.254
      IP4.DOMAIN[1]:                          example.com
      IP6.ADDRESS[1]:                         ip = fe80::5054:ff:fe00:b/64, gw = ::
      
  2. Create a static connection with the same IPv4 address, network prefix, and default gateway. Name the new connection static-eth0.

    [student@serverX ~]$ sudo nmcli con add con-name "static-eth0" ifname eth0 type ethernet ip4 172.25.X.11/24 gw4 172.25.X.254
    Connection 'static-eth0' (f3e8dd32-3c9d-48f6-9066-551e5b6e612d) successfully added.
    
  3. Modify the new connection to add the DNS setting.

    [student@serverX ~]$ sudo nmcli con mod "static-eth0" ipv4.dns 172.25.254.254
    
  4. Display and activate the new connection.

    1. View all connections.

      [student@serverX ~]$ nmcli con show
      NAME         UUID                                  TYPE            DEVICE 
      static-eth0  f3e8dd32-3c9d-48f6-9066-551e5b6e612d  802-3-ethernet  --     
      System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0   
      
    2. View the active connection.

      [student@serverX ~]$ nmcli con show --active
      System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0   
      
    3. Activate the new connection.

      [student@serverX ~]$ sudo nmcli con up "static-eth0"
      Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
      
    4. View the active connection.

      [student@serverX ~]$ nmcli con show --active
      NAME         UUID                                  TYPE            DEVICE 
      static-eth0  f3e8dd32-3c9d-48f6-9066-551e5b6e612d  802-3-ethernet  eth0   
      
  5. Test the connectivity using the new network addresses.

    1. Verify the IP address.

      [student@serverX ~]$ ip addr show eth0
      2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
          link/ether 52:54:00:00:00:0b brd ff:ff:ff:ff:ff:ff
          inet 172.25.X.11/24 brd 172.25.X.255 scope global eth0
             valid_lft forever preferred_lft forever
          inet6 fe80::5054:ff:fe00:b/64 scope link 
             valid_lft forever preferred_lft forever
      
    2. Verify the default gateway.

      [student@serverX ~]$ ip route
      default via 172.25.X.254 dev eth0  proto static  metric 1024 
      172.25.X.0/24 dev eth0  proto kernel  scope link  src 172.25.X.11 
      
    3. Ping the DNS address.

      [student@serverX ~]$ ping -c3 172.25.254.254
      PING 172.25.254.254 (172.25.254.254) 56(84) bytes of data.
      64 bytes from 172.25.254.254: icmp_seq=1 ttl=64 time=0.419 ms
      64 bytes from 172.25.254.254: icmp_seq=2 ttl=64 time=0.598 ms
      64 bytes from 172.25.254.254: icmp_seq=3 ttl=64 time=0.503 ms
      
      --- 172.25.254.254 ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 1999ms
      rtt min/avg/max/mdev = 0.419/0.506/0.598/0.077 ms
      
  6. Configure the original connection so that it does not start at boot and verify that the static connection is used when the system reboots.

    1. Disable the original connection from autostarting at boot.

      [student@serverX ~]$ sudo nmcli con mod "System eth0" \
      > connection.autoconnect no
      
    2. Reboot the system.

      [student@serverX ~]$ reboot
      
    3. View the active connection.

      [student@serverX ~]$ nmcli con show --active
      NAME         UUID                                  TYPE            DEVICE 
      static-eth0  f3e8dd32-3c9d-48f6-9066-551e5b6e612d  802-3-ethernet  eth0   
      
Revision: rh199-7-d0984a3