If you want to hard-code DNS Servers to use on CentOS or Debian, it has 2 methods.
- Configure static DNS with GUI Network manager ( Ubuntu Desktop )
- Configure static DNS in /etc/sysconfig/network-scripts/ifcfg-eth0 (Default is eth0)
- By the way, just edit the config file by following cmd
$
sudovi /etc/
sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes PEERDNS=no
Then, add static DNS to /etc/resolv.conf
$
sudovi /etc/resolv.conf
nameserver 8.8.8.8 nameserver 8.8.4.4
Method 2 (DHCP)
$
sudovi /etc/
sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes DNS1=8.8.8.8 DNS2=8.8.4.4
The DNS servers specified with "DNS1/DNS2" directives will then automatically be added to /etc/resolv.conf when the interface is activated. So there is no need to modify /etc/
resolv.conf yourself.
- Fixed IP
DEVICE=eth0 BOOTPROTO=manual ONBOOT=yes IPADDR=10.0.1.27 NETWORK=10.0.1.0 NETMASK=255.255.255.0 DNS1=8.8.8.8 DNS2=8.8.4.4
- By the way, just edit the config file by following cmd