Linux IP Address Config Example
Step-by-step tutorial for Linux static IP configuration.
-
View the current state of the network card in the IT-Laptop computer.
- From the Favorites bar, select Terminal.
- At the prompt, type ip addr show and press Enter to view the current state of the network adapter.
- Type cd /etc/sysconfig/network-scripts and press Enter.
- 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)
-
Configure the IP version 4 TCP/IP settings for the enp2s0 network connection.
- Type nano ifcfg-enp2s0 and press Enter to edit the first adapter.
- 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.
- Type Ctrl + x to exit the editor.
- Type y to save the modified buffer to the disk.
- Press Enter to save the file using the default name.
-
Configure DNS.
- At the prompt, type nano /etc/resolv.conf and press Enter to configure the DNS server addresses.
- Type nameserver 163.128.78.93 and press Enter to start a new line.
- Type nameserver 163.128.80.93 on the new line.
- Type Ctrl + x to exit the editor.
- Type y to save the modified buffer to the disk.
- Press Enter to save the file using the default name.
- Type ip link set enp2s0 down and press Enter to bring the interface down.
- Type ip link set enp2s0 up and press Enter to bring the interface back up with the new configuration.
-
Use ping to test the corrections to the enp2s0 interface card.
- At the prompt, type ping -c4 192.168.0.5 and press Enter to confirm the connection to the network and default gateway.
- Type ping -c4 163.128.80.93 and press Enter to confirm the connection to the DNS server and the outside network.
No comments to display
No comments to display