Skip to main content

Linux IP Address Config Example

Step-by-step tutorial for Linux static IP configuration.

  1. View the current state of the network card in the IT-Laptop computer.

    1. From the Favorites bar, select Terminal.
    2. At the prompt, type ip addr show and press Enter to view the current state of the network adapter.
    3. Type cd /etc/sysconfig/network-scripts and press Enter.
    4. Type ls and press Enter to view the files in this folder. (Take note of ifcfg-enp2s0, which is the configuration file for the network adapter)
  2. Configure the IP version 4 TCP/IP settings for the enp2s0 network connection.

    1. Type nano ifcfg-enp2s0 and press Enter to edit the first adapter.
    2. Using the keyboard and arrow keys, configure the IP settings as follows:
      • IPADDR=192.168.0.254
      • NETMASK=255.255.255.0
      • BROADCAST=192.168.0.255
      • GATEWAY=192.168.0.5
      • Remove the line that reads BOOTPROTO=dhcp.
    3. Type Ctrl + x to exit the editor.
    4. Type y to save the modified buffer to the disk.
    5. Press Enter to save the file using the default name.
  3. Configure DNS.

    1. At the prompt, type nano /etc/resolv.conf and press Enter to configure the DNS server addresses.
    2. Type nameserver 163.128.78.93 and press Enter to start a new line.
    3. Type nameserver 163.128.80.93 on the new line.
    4. Type Ctrl + x to exit the editor.
    5. Type y to save the modified buffer to the disk.
    6. Press Enter to save the file using the default name.
    7. Type ip link set enp2s0 down and press Enter to bring the interface down.
    8. Type ip link set enp2s0 up and press Enter to bring the interface back up with the new configuration.
  4. Use ping to test the corrections to the enp2s0 interface card.

    1. At the prompt, type ping -c4 192.168.0.5 and press Enter to confirm the connection to the network and default gateway.
    2. Type ping -c4 163.128.80.93 and press Enter to confirm the connection to the DNS server and the outside network.