A static IP address is a permanent and fixed IP address assigned to a device that doesn’t change even after restarting. A static IP address can be configured on a CentOS 6.3 Linux Server by editing the network interface configuration files.
Configuring a static IP address on a CentOS 6.3 Linux Server can provide benefits such as consistency, stability, security, server management, and DNS simplification.
In this tutorial, we will go through the steps required to configure a static IP address on a CentOS 6.3 Linux Server.
Step 1: Find the Network Interface
To configure a static IP address on CentOS 6.3, the first step is to find the network interface that we want to assign the static IP address to. To find the network interface, we can use the “ifconfig” command. Open the terminal and type the following command:
ifconfig
This command will display a list of network interfaces, their IP addresses, and other information.
Step 2: Open Network Interface Configuration File
Once we have found the network interface that we want to assign the static IP address to, we need to open its configuration file. In CentOS 6.3, the network interface configuration files are located in the /etc/sysconfig/network-scripts/ directory. To open the configuration file, we can use any text editor of our choice. For example, to open the configuration file for the network interface “eth0”, we can use the following command:
nano /etc/sysconfig/network-scripts/ifcfg-eth0
Step 3: Configure Static IP Address
In the configuration file, we need to make the following changes:
- Change the value of the “BOOTPROTO” parameter from “dhcp” to “static”.
- Add the “IPADDR” parameter and set its value to the desired static IP address.
- Add the “NETMASK” parameter and set its value to the netmask of the network.
- Add the “GATEWAY” parameter and set its value to the gateway address of the network.
For example, the configuration file for the network interface “eth0” may look like this:
[root@centos63 ~]# nano /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0" BOOTPROTO="static" HWADDR="xx:xx:xx:xx:xx:xx" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="xxxxxxxx-05a0-4adf-84fd-850aca6521c7" IPADDR=192.168.1.54 NETMASK=255.255.255.0
Configure Default gateway:
[root@centos63 ~]# vi /etc/sysconfig/network
NETWORKING=yes HOSTNAME=centos63.ehowstuff.local GATEWAY=192.168.1.1
Step 4: Restart Network Service
After making the changes to the network interface configuration file, we need to restart the network service for the changes to take effect. To restart the network service, we can use the following command:
service network restart
Like this:
[root@centos63 ~]# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ]
Step 5: Verify Static IP Address Configuration
To verify that the static IP address has been successfully configured, we can use the “ifconfig” command again. Open the terminal and type the following command:
ifconfig
This command will display the network interfaces and their IP addresses. Look for the network interface that we configured with the static IP address and verify that the IP address, netmask, and gateway are correct.
Commands Mentioned:
- ifconfig – displays network interfaces, their IP addresses, and other information.
- nano – a text editor that can be used to open the network interface configuration file.
- service network restart – restarts the network service to apply the changes made to the network interface configuration file.
Conclusion:
Great, we have gone through the steps required to configure a static IP address on a CentOS 6.3 Linux Server.
By following the steps outlined in this how-to, we can assign a permanent and fixed IP address to a network interface that doesn’t change even after restarting the server.
1 Comment
Any idea about this error. I’m using centOs 6.3 with vmware.