顯示具有 dns 標籤的文章。 顯示所有文章
顯示具有 dns 標籤的文章。 顯示所有文章

2017/05/09

A workaround on fixing internal DNS not working well in Ubuntu

About

During my works, I need to use an internal DNS for resolving my private domain. However, it does not work quite well. Sometime it resolves the private instantly sometime it just resolving nothing.
I tried to get used to it. However, it really piss me off given that it becomes more and more frequently. So, here is a workaround (solution) I found after digging a really while :)

Workaround: Disable dnsmasq in Ubuntu

  • edit /etc/NetworkManager/NetworkManager.conf
  • comment the dns=dnsmasq line by putting a # in front of it
  • Run command sudo restart network-manager on your terminal

Why it work?

According to a blog here, Ubuntu relies on a dnsmasq local process for handling DNS’s jobs. It works well on VPN scenario. DNS traffics resolve on your local area network instead of routing through your VPN.
However, there is a noticeable statement on how DNSMASQ works on multiple DNS server.
As for dealing with DNS failures, dnsmasq often sends the DNS queries to more
than one DNS servers (if you received multiple when establishing your
connection) and will detect bogus/dead ones and simply ignore them until they
start returning sensible information again.
As a matter of fact that, there are 2 DNS in my Ubuntu. The Primary one is my internal DNS while the 2nd one is a Google DNS 8.8.8.8. Of cause Google DNS returns negative response for my private domain and DNSMASQ shuts everything down as a result.
Therefore, I disable the dnsmasq process which forces the DNS server to be queried in my order.
Everything works harmonically. Perfect :P
​

2017/03/03

Ways on adding DNS servers in Ubuntu

DNS stands for domain name system (Just in case you have no idea what DNS is). This is a system for mapping a hostname and IP address back and forth.
Here are ways for configuring DNS manually in Ubuntu
Background
  • OS: Ubuntu 16.04
1. Edit /etc/hosts
Manually define a static mapping between host and IP address. Although this is the simplest way to do the resolving work, in my opinion, try to avoid editing this file as this is the job of DNS.
For example, given following /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu-server
10.0.0.11 server1
You have added 3 hostnames. When you run command like ping you host is able to resolve the hostname properly.
--- PING localhost (127.0.0.1) 56(84) bytes of data. ---
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.029 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.023 ms
2. Edit /etc/networks/interfaces
Please read my previous blog here. Devices defined here will not be managed by Network Manager below.
3. Network Manager (Recommend)
This is the recommended way for adding DNS in Ubuntu.
In GUI way, you can open network manager in your desktop’s top right hand corner.
Click Edit Connections.
Click Add if you would like to create a new profile. Otherwise, pick a profile and Click Edit
Click to IPV4 Settings tab and add DNS in Additional DNS servers
For example, 8.8.8.8 or multiple 8.8.8.8 8.8.4.4.
In terminal way, you can edit files in /etc/NetworkManager/system-connections.
root@mondwan-VirtualBox:/etc/NetworkManager/system-connections# cat a_custom_profile
[connection]
id=a_custom_profile
uuid=22e9568c-7a0d-3a88-a84d-1e2c0b1708b7
type=ethernet
autoconnect-priority=-999
permissions=
secondaries=
timestamp=1488624882

[ethernet]
duplex=full
mac-address=08:00:27:EB:EB:5B
mac-address-blacklist=

[ipv4]
dns=8.8.8.8;8.8.8.4;
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
ip6-privacy=0
method=auto
Above is a profile named as a_custom_profile and there is an entry ipv4.dns for your DNS.
References:
​