In this blog, we explain you Linux Network Configuration Command Line

Steps to Configure Network in Linux:

  • Setup IP Address
  • Setup Gateway
  • Setup NetMask
  • Name Resolution using /etc/hosts
  • Name Resolution using DNS
  • Setup Hostname

Linux Network related commands:

  • ip route
  • ip addr
  • ifconfig
  • hostname
  • ping
  • dig
  • service

Linux Network Related Files:

  • /etc/sysconfig/network-scripts/ifcfg-eth0
  • /etc/sysconfig/network
  • /etc/resolv.conf
  • /etc/hosts

Eg:

Help-Notes for above configuration:

After Network Configuration restart the network service

Linux Network Commands

If you don’t have DNS Server in your Organization:

You can do the entry in /etc/hosts do the entry of your hostname and IP address.

How it works:

When you ping to your own machine with hostname, first it will go to your /etc/hosts file it will search hostname if it found the hostname then the IP Address is found from their and ping command start working(getting response)

What to do entry in Host file:

How to Set hostname:

To change hostname permanently goto below file:

Even after a reboot, this hostname will be permanent as per the entry in network file.

Temporary change the hostname:

Note: After reboot, this hostname will be lost, it will display the hostname which is there in /etc/sysconfig/network file