Configure network interface part 2
On this article we will know only about how to configure network interface using text mode. So as we know there we have to work on four files those are given below:
- /etc/sysconfig/network-scripts/ifcfg-(Device Name)
- /etc/ sysconfig/network
First of all we need to configure the device file, which is /etc/sysconfig/network-scripts/ifcfg-(Device Name). For my system the device name is enp0s3. So our configuration file will be /etc/sysconfig/network-scripts/ifcfg-enp0s3.
Now we will get the file to edit. Initially we will see the file as shown below.
After we get this we have to add few lines and we have to edit few lines on the device file. So what are the lines we need to edit first! Those lines are given below.
Now we have to edit these lines according to below.
Once these lines are edited then we have to add few lines with it. Those are given below.
Now change the ip address, prefix number, gateway and dns as provided by the ISP. Then simply save and exit the file. After that run a command to recheck the file.
The output will be like
Once this work is done we have successfully completed 50% our work. The network will work if we edit this file only. Now to make it more accurate we need to edit the rest of three files.
One this step we have to edit the file /etc/sysconfig/network. This file is important when we have more than one gateway to work with.
We need to add three lines on this file.
Now we will edit the third file which is /etc/hosts. This file helps to resolve the server itself and the servers we need to know from the network. So we have to add the below line at the end of the file.
192.168.1.64 testserver.doamin-name.com testserver
Then we have to save and exit from the file. Now we have only one file left to edit and we are done with our network configuration.
The last file is /etc/resolve.conf.
Here we have to add the name servers using either IP address or by using domain names.
Top open this file we have to use the vi or vim editor again. So that will be like as mentioned in below.
We have to add the nameservers at the end of the file and then we have to save the file and exit the file.
Once we are done with all those above work we are ready to restart the network service. For that we have to run the command mentioned below.
#systemctl restart network
On this stage we can say that our network ready to use. So to be sure we will run another command and make sure that our network is working properly.
If we get response from the ping then we can start our rest of the work without wasting time.