- Open ifcfg-Auto_eth0 file at /etc/sysconfig/network-scripts folder
- sudo vi /etc/sysconfig/network-scripts/ifcfg-Auto_eth0
- The file name could be different. It could be ifcfg_eth0, too.
- Change the content to something like below:
- TYPE=Ethernet
 BOOTPROTO=none
 IPADDR=192.168.11.30
 PREFIX=24
 GATEWAY=192.168.11.1
 DNS1=192.168.11.10
 DNS2=209.18.47.62
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=yes
 IPV6INIT=no
 NAME=eth0
 UUID=06823066-d18a-4af3-b3a0-e2158d152465
 ONBOOT=yes
 HWADDR=00:0C:29:D3:6C:5C
 LAST_CONNECT=1523339343
- :wq
- Open resolv.conf and check or correct the nameserver
- sudo vi /etc/resolv.conf
- It should be like the following.
- nameserver 192.168.11.10
- nameserver 209.18.47.62
- Restart network
- sudo /etc/init.d/network restart
Other admins use /etc/sysconfig/network file to specify the default gateway. They may not specify DNS1 or DNS2 in ifcfg-eth0 or ifcfg-Auto_eth0 file. Instead, only the /etc/sysconfig/network file is used to specify the nameservers. 
Below is another example of setting up static ip on CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:CC:37:F1:03
TYPE=Ethernet
BOOTPROTO=static
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
IPADDR=192.168.11.30
NETMASK=255.255.255.0
## Configure Default Gateway
#
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=centos6
GATEWAY=192.168.11.1
## Restart Network Interface
#
/etc/init.d/network restart
## Configure DNS Server
#
# vi /etc/resolv.conf
nameserver 192.168.11.10      # Replace with your nameserver ip
nameserver 209.18.47.62       # Replace with your nameserver ip
 
 
No comments:
Post a Comment