I have installed ubuntu server in Virtual Machine. I started exploring about the network, and read a book for it.
It says that my DNS server is given in /etc/resolv.conf file.
This is my server's IP.
luvpreet@server16:~$ hostname -I
192.168.122.62 This is the /etc/resolv.conf file,
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.122.1Well, DNS server maps the human readable addresses to IP addresses. In my main machine(not in VM)
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2332/dnsmasq The DNS server is running.
But how it works, I have no idea that how this IP address i.e, 192.168.122.1 is serving as my DNS Server. Please explain its working in detail and also the flow by which this DNS server works.
I know how a DNS server works, it is like a phonebook which helps us to locate to a particular website. Where is the DNS cache? I want to know how this IP address is working as my DNS server ? Can I bind any IP address as my DNS server ?If yes, How to do that ? If no, why ?
Sorry if this is dumb but I am not getting this.
1 Answer
Your question is too fuzzy for me, but anyway I try to clarify some of the things.
As you know 192.168.122.62 is your server (VM) IP, and you should be sitting on 192.168.122.0/24 network.
If you run ifconfig -a on your host machine, I'm pretty sure you will get 192.168.122.1 as one of your interfaces IP address, it should be on a virtual interface created by your hypervisor, which can be VirtualBox for example.
At the same time I guess your virtual network is behind a NAT (Network address translation), and your host is acting as a router for your VMs.
And thats why when you lookup your resolve.conf you get your host IP, in fact your host, which is a router to your VM, is responsible of resolving DNS requests.
You can run ip r or route or netstat -nr on your VM to see your routing table.
It's been a long time that i'm not using dnsmasq, but if I remember corectly if you send a USR1 signal to it's process it will generates some log about cached addresses at its service status, something like this:
kill -USR1 `pidof dnsmasq`If you want to run a DNS server: BIND9
To know more about dnsmasq which are listening on your host: Dnsmasq