How to Set up a DNS server in Ubuntu

Source: Internet
Author: User
The following is the basic solution for setting up DNS servers in Ubuntu. Because network-manager always causes various problems, you can uninstall it in anger and manually modify/etc/network/interfaces as follows: # Thisfiledescribesthenetworkinterfacesavailableonyoursystem # andhowtoactivatethem.

The following is the basic solution for setting up DNS servers in Ubuntu.

Because network-manager always causes various problems, you can uninstall it in anger and manually modify/etc/network/interfaces as follows:

# This file describes the network interfaces available on your system
# And how to activate them. For more information, see interfaces (5 ).

# The loopback network interface
Auto lo
Iface lo inet loopback

# The primary network interface
Auto eth0
Iface eth0 inet static
Address 192.168.2.10
Netmask 255.255.255.0
Gateway 192.168.2.1

Because I use Route dialing, it is easier to set a static address. The problem is that the DNS server address cannot be saved, and the modification to/etc/resolv. conf is useless. After the restart, it will become unavailable. What google can find is also a method that has been reproduced before. The root cause of this method is to modify/etc/dhcp3/dhclient. conf to add the DNS server. Now I have configured eth0 as a static address, so I cannot use it. This problem is found because usepeerdns in/etc/ppp/peers/dsl-provide needs to be commented out in this method, but I don't have this file at all! After testing and restarting n times, I finally found a solution. The key is that the dns information is provided by/etc/resolv. conf, and the file is still blank after I set its permission to 444. This means that this file is generated during the boot process. After a mess is found, it is generated by/sbin/resolvconf-u. The three file names are completely clear, so it is easy to add the dns to the base (the other two are actually the same. For example, to use an OpenDNS server, you only need to perform the following operations:


Su
Echo "nameserver 208.67.220.220">/etc/resolvconf/resolv. conf. d/base
Echo "nameserver 208.67.222.222">/etc/resolvconf/resolv. conf. d/base

In fact, as long as you know that the DNS server is set in/etc/resolv. conf, there is a very simple solution: add a sentence in/etc/rc. local:


Echo "nameserver 208.67.220.220">/etc/resolv. conf

This is equivalent to automatically configuring the DNS server once every boot-but this solves the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.