In CentOS operating system, we can configure IP address in two ways. One is using graphical mode and the other is using command line mode. Again, during the operating system installation time an IP address can be configured. However, in order to configure the IP address graphically, the graphical environment must be pre-installed. In this tutorial, we will learn how to configure IP using command line mode.
We know that, when a network interface card is inserted into the CentOS operating system, a script file is generated. By editing that script file, we can configure the IP address for that network interface card. The location of the file is: -
One thing we need to keep in mind here is that, the name for the first network card will be “ifcfg-eth0”, then the name for the second will be “ifcfg-eth1”, the name for the third will be “ifcfg-eth2”, and so on.
Now we will open the script of that network card using “VI editor”. If you want, you can use any editor other than "VI Editor". The complete command to open the file is: -
Since, after opening the file it will be in “read only” mode, so we will have to go to “insert” mode. To go into “insert” mode we need to press “i” from the keyboard.
After opening the file, we will add some lines here. The lines are: -
IPADDR=192.168.3.61
NETMASK=255.255.255.0
GATEWAY=192.168.3.253
One thing to note here is that, by default CentOS operating system enables "dhcp" mode for IP address configuration.
After configuring our IP address, we have to configure our DNS address. The file we need to edit to configure the DNS address is:
No comments:
Post a Comment