Ads

Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts

Thursday, 18 May 2017

ProviderPrimary DNS ServerSecondary DNS Server
Level31209.244.0.3209.244.0.4
Verisign264.6.64.664.6.65.6
Google38.8.8.88.8.4.4
DNS.WATCH484.200.69.8084.200.70.40
Comodo Secure DNS8.26.56.268.20.247.20
OpenDNS Home5208.67.222.222208.67.220.220
Norton ConnectSafe6199.85.126.10199.85.127.10
GreenTeamDNS781.218.119.11209.88.198.133
SafeDNS8195.46.39.39195.46.39.40
OpenNIC996.90.175.167193.183.98.154
SmartViper208.76.50.50208.76.51.51
Dyn216.146.35.35216.146.36.36
FreeDNS1037.235.1.17437.235.1.177
Alternate DNS11198.101.242.7223.253.163.53
Yandex.DNS1277.88.8.877.88.8.1
UncensoredDNS1391.239.100.10089.233.43.71
Hurricane Electric1474.82.42.42 ........
puntCAT15

109.69.8.51 .......
Read More

Friday, 31 March 2017



I installed DNSMasq and added localhost to the listen-address in the conf file. However, when I try to start it, I get this:

Code:
brandon@ubuntu-server:~$ sudo /etc/init.d/dnsmasq start
 * Starting DNS forwarder and DHCP server dnsmasq
dnsmasq: failed to create listening socket: Address already in use
 * failed
                                                             [fail]






Read More

Friday, 30 September 2016

Basic DNS Setup

First things first, let's install the package:
apt-get update
apt-get install dnsmasq
If your goal was to set up a simple DNS server, you just succeeded. To test it, use your favorite DNS lookup tool pointed at localhost:
dig debian.org @localhost
or
nslookup debian.org localhost
By default, DNS is configured to forward all requests to your system's default DNS settings. In case you didn't know, these are stored in the /etc/resolv.conf file. See Debian Reference or the resolv.conf(5) man page for more details.
Now, if you want to add some names for your DNS server to resolve for your clients, simply add them to your /etc/hosts file.

Choosing Your Interfaces

One you will probably want to do is tell dnsmasq which ethernet interface it can and cannot listen on, as we really don't want it listening on the internet. Around line 69 of the/etc/dnsmasq.conf file, you will see:
#interface=
Uncomment the line and specify which ethernet interface(s) you want it server IPs to. For example, if I want it to listen on eth1 (my DMZ) and eth2 (my local network), then it should look like:
interface=eth1
interface=eth2
If I didn't edit this line, it would also listen on eth0, my internet connection. I personally wouldn't recommend this, as it gives those evil guys a few doors to try to break into.

Basic DHCP Setup

By default, DHCP is turned off. This is a good thing, as you could bring down whatever network you are connected to if you are not careful.
To enable it, there is at least one line will need to edit in the /etc/dnsmasq.conf file. Around line 143, you will see:
#dhcp-range=192.168.0.50,192.168.0.150,12h
To enable the DHCP server, you will need to give it a range of IP addresses to hand out. In the example above, this server would hand out 101 address starting at 192.168.0.50 and ending at 192.168.0.150. The last number is how long the DHCP leases are good for. In this example, they would be good for twelve hours.
Since I have two different networks that need DHCP, I'm going to change that line to:
dhcp-range=eth1,192.168.100.100,192.168.100.199,4h
dhcp-range=eth2,192.168.200.100,192.168.200.199,4h
Notice the "eth1" and "eth2" labels in the lines above? The aren't necessary, but definately help once you start playing with more advanced configurations. It also helps me remember which range is which. Now restart your dnsmasq server, connect up a few clients, and see if they autoconfigure themselves:
/etc/init.d/dnsmasq restart

Local Caching

Using dnsmasq to cache DNS queries for the local machine is a bit tricky (unless you're using NetworkManager, see below), since all DNS queries from the local machine need to go to dnsmasq, while as the same time, dnsmasq must be configured to forward all those queries to upstream DNS servers.
  • <!> Do not use this configuration if you use different network (e.g If you use a laptop!)
The dnsmasq(8) man page suggests the following:
  • In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in /etc/resolv.conf to force local processes to send queries to dnsmasq. Then either specify the upstream servers directly to dnsmasq using --server options or put their addresses real in another file, say /etc/resolv.dnsmasq and run dnsmasq with the -r /etc/resolv.dnsmasq option. This second technique allows for dynamic update of the server addresses by PPP or DHCP.
There is, however, a simpler method; simply ensure that the machine's list of nameservers contains the line
nameserver 127.0.0.1
as the first line, followed by the upstream nameservers. dnsmasq is smart enough to ignore this line and forward all queries appropriately, while all other applications will send all their queries to dnsmasq.
Exaclty how to do this depends on the method(s) of network configuration in use. If you're manually hardcoding the nameservers (either in /etc/resolv.conf or elsewhere, such as a stanza in /etc/network/interfaces or in the Wicd GUI), then just add a reference to 127.0.0.1 as the first entry in the list. If you're using DHCP, then instruct your client to prepend127.0.0.1 to the DHCP servers it receives. E.g., with dhclient, include the line
prepend domain-name-servers 127.0.0.1;
in the dhclient configuration file (/etc/dhcp3/dhclient.conf). [On my Sid system, the default configuration file shipped with the package contains that line, but commented out.]
Note that if you plan to use dnsmasq for the local system only, you should lock it down by adding the line
listen-address=127.0.0.1
to the dnsmasq configuration file (/etc/dnsmasq.conf).

Local Caching using NetworkManager

Set this in /etc/NetworkManager/NetworkManager.conf:
[main]
dns=dnsmasq
and restart network-manager service.

dnsmasq with dnscrypt-proxy

dnsmasq combined with dnscrypt-proxy provide caching, encryption and server-side authentication. Useful to protect a laptop from potentially hostile networks.

apt-get install dnsmasq dnscrypt-proxy

## Configure /etc/resolv.conf to use dnsmasq
nameserver 127.0.0.1

## Configure /etc/dnsmasq.conf
# ignore resolv.conf
no-resolv
# Listen only on localhost
listen-address=127.0.0.1
# dnscrypt is on port 40
server=127.0.0.1#40

## Configure /etc/systemd/system/sockets.target.wants/dnscrypt-proxy.socket with the following 5 lines if you are using systemd
[Socket]
ListenStream=
ListenDatagram=
ListenStream=127.0.0.1:40
ListenDatagram=127.0.0.1:40

## restart both daemons










Read More

Sunday, 10 April 2016

About DNS

DNS, stands for Domain Name System, translates hostnames or URLs into IP addresses. For example, if we typewww.uskysolution.com in browser, the DNS server translates the domain name into its associated ip address. Since the IP addresses are hard to remember all time, DNS servers are used to translate the hostnames like www.uskysolution.com to 173.xxx.xx.xxx. So it makes easy to remember the domain names instead of its IP address.
In this tutorial, we will see how to setup and configure DNS server on Ubuntu 15.10 server. Also, the same method will work on Debian and its derivatives.

Setup DNS Server In Ubuntu 15.10

Scenario

For the purpose of this tutorial, I will be using three systems. One will be acting as Master DNS server, the second system will be acting as Secondary DNS, and the third will be ourDNS client. Here are my three systems details.

Primary (Master) DNS Server Details:

Operating System     : Ubuntu 15.10 64bit minimal server
Hostname             : masterdns.uskywifi.local
IP Address           : 192.168.1.101/24

Secondary (Slave) DNS Server Details:

Operating System     : Ubuntu 15.10 64bit minimal server
Hostname             : secondarydns.uskywifi.local
IP Address           : 192.168.1.102/24

Client Details:

Operating System     : Ubuntu 14.04 desktop
Hostname             : client.uskywifi.local
IP Address           : 192.168.1.103/24

Setup Caching Server

In this configuration, BIND9 will find the answer to name queries and remember the answer for the next query. This can be useful for a slow internet connection. By caching DNS queries, you will reduce bandwidth and (more importantly) latency.
The default configuration is setup to act as a caching server. All that is required is simply adding the IP Addresses of your ISP’s DNS servers. Caching server is opt for low Internet connection.
Install bind9 packages using command:
sudo apt-get install bind9 bind9utils bind9-doc
Then edit /etc/bind/named.conf.options file,
sudo vi /etc/bind/named.conf.options
Simply uncomment and edit the following in /etc/bind/named.conf.options:
forwarders {
8.8.8.8;
};
Restart bind9 service.
sudo systemctl restart bind9

Test Caching Server

Run the following command to test it.
dig -x 127.0.0.1
Sample output:
; <<>> DiG 9.9.5-11ubuntu1-Ubuntu <<>> -x 127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60612
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.127.in-addr.arpa.        IN    PTR
;; ANSWER SECTION:
1.0.0.127.in-addr.arpa.    604800    IN    PTR    localhost.
;; AUTHORITY SECTION:
127.in-addr.arpa.    604800    IN    NS    localhost.
;; ADDITIONAL SECTION:
localhost.        604800    IN    A    127.0.0.1
localhost.        604800    IN    AAAA    ::1
;; Query time: 4 msec
;; SERVER: 192.168.1.101#53(192.168.1.101)
;; WHEN: Mon Nov 23 17:48:36 IST 2015
;; MSG SIZE  rcvd: 132

Setup Primary (Master) DNS Server

You can use the same server for both Primary and Caching server.
Install bind9 packages on your server if not installed.
sudo apt-get install bind9 bind9utils bind9-doc

1. Configure Master DNS Server

DNS configuration files are stored in /etc/bind directory. Primary configuration file is/etc/bind/namd.conf.
Edit ‘/etc/bind/named.conf’ file.
sudo vi /etc/bind/named.conf
Make sure it contains the following lines. If not, add them.
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
Save and close the file.
Then, edit named.conf.local,
sudo vi /etc/bind/named.conf.local
Add the following lines:
zone "uskywifi.local" {
        type master;
        file "/etc/bind/forward.uskywifi";
        allow-transfer { 192.168.1.102; };
        also-notify { 192.168.1.102; };
 };
zone "1.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/reverse.uskywifi";
        allow-transfer { 192.168.1.102; };
        also-notify { 192.168.1.102; };
 };
Here,
  • forward.uskywifi – Forward zone file
  • reverse.uskywifi – Reverse zone file
  • 192.168.1.102 – Slave DNS server IP address

2. Create Zone files

Create forward and reverse zone files which we defiend in the‘/etc/bind/named.conf.local’ file.

2.1 Create Forward Zone

Create Forward Zone file name forward.uskywifi in /etc/bind/zones,
sudo vi /etc/bind/forward.uskywifi
Add the following lines:
$TTL 86400
@   IN  SOA     masterdns.uskywifi.local. root.uskywifi.local. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          masterdns.uskywifi.local.
@       IN  NS          secondarydns.uskywifi.local.
@       IN  A           192.168.1.101
@       IN  A           192.168.1.102
@       IN  A           192.168.1.103
masterdns       IN  A   192.168.1.101
secondarydns    IN  A   192.168.1.102
client          IN  A   192.168.1.103

2.2 Create Reverse Zone

Create Forward Zone file name reverse.uskywifi in /etc/bind/zones,
sudo vi /etc/bind/reverse.uskywifi
Add the following lines:
$TTL 86400
@   IN  SOA     masterdns.uskywifi.local. root.uskywifi.local. (
        2011071002  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          masterdns.uskywifi.local.
@       IN  NS          secondarydns.uskywifi.local.
@       IN  PTR         uskywifi.local.
masterdns       IN  A   192.168.1.101
secondarydns    IN  A   192.168.1.102
client          IN  A   192.168.1.103
101     IN  PTR         masterdns.uskywifi.local.
102     IN  PTR         secondarydns.uskywifi.local.
103     IN  PTR         client.uskywifi.local.

3. Configuring Permissions, Ownership for Bind

Run the following commands one by one:
sudo chmod -R 755 /etc/bind
sudo chown -R bind:bind /etc/bind

4. Test DNS configuration and zone files for any syntax errors

Check DNS default configuration file:
sudo named-checkconf /etc/bind/named.conf
sudo named-checkconf /etc/bind/named.conf.local
If it returns nothing, your configuration is valid.
Check Forward zone:
sudo named-checkzone uskywifi.local /etc/bind/forward.uskywifi
Sample output:
zone uskywifi.local/IN: loaded serial 2011071001
OK
Check reverse zone:
sudo named-checkzone uskywifi.local /etc/bind/reverse.uskywifi 
Sample Output:
zone uskywifi.local/IN: loaded serial 2011071002
OK
Restart bind9 service.
sudo systemctl restart bind9
Add the DNS Server details in your network interface config file.
sudo vi /etc/network/interfaces
Add the nameserver IP address:
auto enp0s3
iface enp0s3 inet static
        address 192.168.1.101
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        dns-nameservers 192.168.1.101
        dns-search uskywifi.local
Reboot your system.

5. Test DNS Server

Method 1:
dig masterdns.uskywifi.local
Sample Output:
; <<>> DiG 9.9.5-11ubuntu1-Ubuntu <<>> masterdns.uskywifi.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27712
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;masterdns.uskywifi.local.    IN    A
;; ANSWER SECTION:
masterdns.uskywifi.local. 86400    IN    A    192.168.1.101
;; AUTHORITY SECTION:
uskywifi.local.        86400    IN    NS    masterdns.uskywifi.local.
uskywifi.local.        86400    IN    NS    secondarydns.uskywifi.local.
;; ADDITIONAL SECTION:
secondarydns.uskywifi.local. 86400 IN    A    192.168.1.102
;; Query time: 4 msec
;; SERVER: 192.168.1.101#53(192.168.1.101)
;; WHEN: Mon Nov 23 17:55:00 IST 2015
;; MSG SIZE  rcvd: 125
Method 2:
nslookup uskywifi.local
Sample Output:
Server:        192.168.1.101
Address:    192.168.1.101#53
Name:    uskywifi.local
Address: 192.168.1.101
Name:    uskywifi.local
Address: 192.168.1.102
Name:    uskywifi.local
Address: 192.168.1.103
Now the Primary DNS server is ready to use.
It is time to configure our Secondary DNS server.

Setup Secondary(Slave) DNS Server

Secondary DNS server is optional, but recommended. If the master DNS server goes down, the Secondary DNS server will take charge and answer the queries. You need an additional server to setup Slave DNS server.
Install bind9 packages using the following command:
sudo apt-get install bind9 bind9utils bind9-doc

1. Configure Slave DNS Server

Edit ‘/etc/bind/named.conf’ file.
sudo vi /etc/bind/named.conf
Make sure it contains the following lines. If not, add them.
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
Save and close the file.
Then, edit named.conf.local,
sudo vi /etc/bind/named.conf.local
Add the lines as shown in bold:
zone "uskywifi.local" {
        type slave;
        file "/var/cache/bind/forward.uskywifi";
        masters { 192.168.5.101; };
 };
zone "1.168.192.in-addr.arpa" {
        type slave;
        file "/var/cache/bind/reverse.uskywifi";
        masters { 192.168.5.101; };
 };
Here,
  • forward.uskywifi – Forward zone file
  • reverse.uskywifi – Reverse zone file
  • 192.168.1.101 – Master DNS server IP address
The zone file must be in /var/cache/bind/ because, by default, AppArmor only allows write access inside it.

3. Configuring Permissions, Ownership for Bind

Run the following commands one by one:
sudo chmod -R 755 /etc/bind
sudo chown -R bind:bind /etc/bind
Restart bind9 service.
sudo service bind9 restart

4. Add the DNS Server details

Add the DNS Server details in your network interface config file.
sudo vi /etc/network/interfaces
# 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 enp0s3
iface enp0s3 inet static
address 192.168.1.102
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.101
dns-nameservers 192.168.1.102
dns-search home
Save and close the file.
Reboot your system.

5. Test DNS Server

After logging in to your server, run the following commands to check if DNS server is really working or not.
Method 1:
dig masterdns.uskywifi.local
Sample Output:
; <<>> DiG 9.9.5-3-Ubuntu <<>> masterdns.uskywifi.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20290
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;masterdns.uskywifi.local.    IN    A
;; ANSWER SECTION:
masterdns.uskywifi.local. 86400    IN    A    192.168.1.101
;; AUTHORITY SECTION:
uskywifi.local.        86400    IN    NS    masterdns.uskywifi.local.
uskywifi.local.        86400    IN    NS    secondarydns.uskywifi.local.
;; ADDITIONAL SECTION:
secondarydns.uskywifi.local. 86400 IN    A    192.168.1.102
;; Query time: 5 msec
;; SERVER: 192.168.1.101#53(192.168.1.101)
;; WHEN: Mon Nov 23 18:02:38 IST 2015
;; MSG SIZE  rcvd: 125
Method 2:
dig secondarydns.uskywifi.local
Sample Output:
; <<>> DiG 9.9.5-3-Ubuntu <<>> secondarydns.uskywifi.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53461
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;secondarydns.uskywifi.local. IN A
;; ANSWER SECTION:
secondarydns.uskywifi.local. 86400 IN A 192.168.1.102
;; AUTHORITY SECTION:
uskywifi.local. 86400 IN NS masterdns.uskywifi.local.
uskywifi.local. 86400 IN NS secondarydns.uskywifi.local.
;; ADDITIONAL SECTION:
masterdns.uskywifi.local. 86400 IN A 192.168.1.101
;; Query time: 5 msec
;; SERVER: 192.168.1.101#53(192.168.1.101)
;; WHEN: Mon Nov 23 18:10:02 IST 2015
;; MSG SIZE rcvd: 125
Method 3:
nslookup unixmen.local
Sample Output:
Server:        192.168.1.101
Address:    192.168.1.101#53
Name:    uskywifi.local
Address: 192.168.1.101
Name:    uskywifi.local
Address: 192.168.1.103
Name:    uskywifi.local
Address: 192.168.1.102
Note: A zone is only transferred if the Serial Number on the Primary DNS server is larger than the one on the Secondary DNS server.

Client Side Configuration

Add the DNS server details in ‘/etc/resolv.conf’ file in all client systems
vi /etc/resolv.conf
# Generated by NetworkManager
search uskywifi.local
nameserver 192.168.1.101
nameserver 192.168.1.102
Restart network service or reboot the system.

Test DNS Server

Now, you can test the DNS server using any one of the following commands:
dig masterdns.uskywifi.local
dig secondarydns.uskywifi.local
dig client.uskywifi.local
nslookup uskywifi.local




Read More

Recent News