1

I managed to setup bind on my local network in order to resolve domains to the local IP of my server instead of my public IP. However it only works on other clients in the network, but not from the server itself.

Here is my config :

/etc/bind/db.mydomain.be

$ORIGIN mydomain.be.

    $TTL    3600
    @   IN  SOA ns1.local. me.ff. (
                      5     ; Serial
                     1h     ; Refresh
                    30m     ; Retry
                     7d     ; Expire
                    15m )   ; Negative Cache TTL
    ;
    @   IN  NS  ns1.local.
    @   IN  A   192.168.1.105
    *   IN  A   192.168.1.105

/etc/bind/named.conf.options

options {
    directory "/var/cache/bind";
    recursion yes;                 # enables resursive queries
    listen-on { 192.168.1.105; };
    allow-recursion { localnets; }; 
    allow-transfer { none; };

    forwarders {
        8.8.8.8;
        8.8.4.4;
    };

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
    dnssec-validation auto;
};

From a pc on my network : ping mydomain.be - > resolves as expected to my server 192.168.1.105

Same ping command on the server itself : ping mydomain.be - > resolves to my public ip address 141.135.154.217. I need it to resolve to it's onw IP 192.168.1.105

What am I missing ? It looks like "ping mydomain.be" from the server itself, just passes on to my DNS forwarders. Which in turn will respond with my public iP.

2
  • did you setup your server to use itself as its DNS? How this can be done is somewhat Ubuntu version dependent. I am still using Ubuntu 16.04, because i do not like Netplan, and I do it via the /etc/network/interfaces file. Oh, and allow bind to listen to the loopback interface also. Dec 12, 2018 at 22:29
  • I'm using bionic beaver 18.04. And yes, it uses the netplan thing. How can I get the ip of the loopback interface?
    – maarten
    Dec 12, 2018 at 22:40

1 Answer 1

0

Ok, the solution is simple (Ubuntu 18.04) :

1) Edit /etc/dhcp/dhclient.conf and uncomment or add this line :

prepend domain-name-servers 127.0.0.1;

2) reload dhclient :

sudo dhclient

=> It does however only work the first time I ping my domain (just after executing sudo dhclient). The second time I ping, it's again my public IP

2
  • I used to do it this way for Ubuntu 14.04, but my notes in my dhclient.conf file say it no longer worked for 16.04. You deleted domain-name-servers from your dhcp request line, right? Anyway, not sure how to help. Dec 12, 2018 at 23:16
  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12, 2018 at 23:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .