Configure networking and hostname resolution statically or dynamically

John Coltrane is a saxophone genius by night, and a RHEL Syadmin at Google by day:

  • His RHEL Server: A_Love_Supreme_Server_001
  • His username: john.coltrane@google.com
  • His certifications: LFCS, RHCSA, RHCE
  • His prefence: never run programs as root
  • His assigned task: Configure networking and hostname resolution statically or dynamically

Please list and explain all of the commands that John is going to have to execute for both static and dynamic hostname resolution on his RHEL Server.

  1. View network interfaces: John can use the ip addr or ifconfig command to view the available network interfaces on his RHEL server. This will help him identify the interface he wants to configure.

  2. Configure networking statically: If John wants to configure networking statically, he can use the following commands:

    • Edit the network configuration file:

    • sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface-name>
    • Replace <interface-name> with the name of the network interface he wants to configure, such as eth0.

    • Configure the interface with a static IP address, subnet mask, gateway, and DNS:

    • DEVICE=<interface-name>
      BOOTPROTO=none
      ONBOOT=yes
      IPADDR=<ip-address>
      NETMASK=<subnet-mask>
      GATEWAY=<gateway-address>
      DNS1=<dns-server1>
      DNS2=<dns-server2>
    • Replace <interface-name>, <ip-address>, <subnet-mask>, <gateway-address>, <dns-server1>, and <dns-server2> with the appropriate values.

    • Save and exit the file.

    • Restart the network service:

    • sudo systemctl restart network
  3. Configure networking dynamically (DHCP): If John wants to configure networking dynamically using DHCP, he can use the following command:

    • Edit the network configuration file:

    • sudo vi /etc/sysconfig/network-scripts/ifcfg-<interface-name>
    • Replace <interface-name> with the name of the network interface he wants to configure, such as eth0.

    • Configure the interface to obtain IP address and DNS information dynamically:

    • DEVICE=<interface-name>
      BOOTPROTO=dhcp
      ONBOOT=yes
    • Save and exit the file.

    • Restart the network service:

    • sudo systemctl restart network
  4. Configure hostname: To configure the hostname on his RHEL server, John can use the following commands:

    • Set the hostname:

    • sudo hostnamectl set-hostname <hostname>
    • Replace <hostname> with the desired hostname for his RHEL server.

    • Edit the hosts file:

    • sudo vi /etc/hosts
    • Add or modify the line that includes the IP address and hostname:
    • <ip-address> <hostname>
    • Save and exit the file.
    • Restart the network service:
    • sudo systemctl restart network
  5. Verify configuration: John can use the following commands to verify his networking and hostname configuration:

    • Check network interfaces and IP configuration:

    • ip addr
    • Check hostname:
    • hostname
    • Check hostname resolution:
    • ping <hostname>

That's it! These commands should help John configure networking and hostname resolution, both statically and dynamically, on his RHEL server.

You should also read:

Configure a caching DNS server

Segun is a RHEL Sysadmin at Red Hat. He administers RHEL_Server_047, and his username is segun.okuns. His supervisor wants Segun to demonstrate how…