Add DNS Server Address In Ubuntu Fedora Centos Redhat etc

After installing a Linux Operating system and configuring a Static ip address, you may need to add one or more DNS servers to resolve names. Then only you can communicate with domain names of websites and other servers. You can add more than one DNS server addresses as primary, secondary and so on.

This configuration should work in all Linux distributions like Redhat, CentOS, Ubuntu, Debian, Fedora, etc


Without a DNS server
Without a DNS server you can communicate with all servers by their ip addresses, and cannot communicate by their domain names.
[root@server ~]#  ping facebook.com
ping: unknown host facebook.com

Add DNS server Addresses
Add your DNS server address to the configuration file located in "/etc/resolv.conf"  as below. here i added Google's public DNS server addresses as my DNS server.
[root@server ~]# vi /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.4.4
#Now save the resolv.conf configuration file




Add DNS server in Interface config file
In RPM based Distributions like Redhat, CentOS, Fedora You can also add DNS server information in Network interface configuration file located in  
/etc/sysconfig/network-scripts/ifcfg-ethX
[root@server ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.10.50
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes
GATEWAY=192.168.10.1
DNS1=192.168.10.2
DNS2=192.168.10.3
DNS3=192.168.10.4

Test DNS Server
You not need to restart network daemon, 
Just go to browser and connect to any websites by name 
ping to websites
or [root@server ~]# host facebook.com
facebook.com has address 69.171.229.11
facebook.com has address 66.220.149.11
facebook.com has address 69.171.224.11
facebook.com mail is handled by 10 smtpin.mx.facebook.com.

0 comments:

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons