User Tools

Site Tools


wiki:add_dns_server

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:add_dns_server [2017/01/12 11:46] – created walkeradminwiki:add_dns_server [2023/03/09 22:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Add DNS Server ====== ====== Add DNS Server ======
-\\ +<color orange>Jan 2017</color> 
 + 
 +---- 
 + 
 Normally we just add the IP Address, Subnet Mask and Gateway to the ifcfg-eth0 file, as that is all we need. But if it is required that we need to update the OS, or add a piece of software (htop for example) then we may need to add the DNS settings. Normally we just add the IP Address, Subnet Mask and Gateway to the ifcfg-eth0 file, as that is all we need. But if it is required that we need to update the OS, or add a piece of software (htop for example) then we may need to add the DNS settings.
 +\\ 
 +\\ 
 +While this was written with CentOs 6/7 in mind, it may work for other Linux distributions.
 \\  \\ 
 \\  \\ 
Line 7: Line 14:
 \\  \\ 
 \\  \\ 
 +
 +----
 +
 ==== Method 1 ==== ==== Method 1 ====
 \\  \\ 
 +Use "PEERDNS=no". This option will prevent /etc/resolv.conf from being modified by a DHCP server. So instead of using DHCP-provided DNS, you can specify any arbitrary DNS servers you want to use in /etc/resolv.conf.
 +\\ 
 +\\ 
 +The configuration file for your network interface (e.g., eth0) looks like the following.
 +\\ 
 +\\ 
 +**//sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0//**
 +\\ 
 +\\ 
 +DEVICE=eth0\\ 
 +BOOTPROTO=dhcp\\ 
 +ONBOOT=yes\\ 
 +**PEERDNS=no**\\ 
 +\\ 
 +\\ 
 +Then, add static DNS to /etc/resolv.conf
 +\\ 
 +\\ 
 +**//sudo vi /etc/resolv.conf//**
 +\\ 
 +\\ 
 +nameserver 8.8.8.8\\ 
 +nameserver 8.8.4.4\\ 
 +\\ 
 +\\ 
 +
 +----
 +
 +==== Method 2 ====
 +\\ 
 +Alternatively, you can specify DNS servers directly in the interface configuration file, instead of modifying /etc/resolv.conf yourself. That is:
 +\\ 
 +\\ 
 +**//sudo vi /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.
  
wiki/add_dns_server.1484221587.txt.gz · Last modified: 2023/03/09 22:35 (external edit)