Domains resolving to public IP instead of local IP with BIND












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.










share|improve this question






















  • 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.
    – Doug Smythies
    Dec 12 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 at 22:40
















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.










share|improve this question






















  • 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.
    – Doug Smythies
    Dec 12 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 at 22:40














1












1








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.










share|improve this question













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.







dns bind






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 12 at 22:23









maarten

204




204












  • 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.
    – Doug Smythies
    Dec 12 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 at 22:40


















  • 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.
    – Doug Smythies
    Dec 12 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 at 22:40
















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.
– Doug Smythies
Dec 12 at 22:29






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.
– Doug Smythies
Dec 12 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 at 22:40




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 at 22:40










1 Answer
1






active

oldest

votes


















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






share|improve this answer























  • 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.
    – Doug Smythies
    Dec 12 at 23:16










  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12 at 23:56











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1100474%2fdomains-resolving-to-public-ip-instead-of-local-ip-with-bind%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









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






share|improve this answer























  • 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.
    – Doug Smythies
    Dec 12 at 23:16










  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12 at 23:56
















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






share|improve this answer























  • 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.
    – Doug Smythies
    Dec 12 at 23:16










  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12 at 23:56














0












0








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






share|improve this answer














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







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 12 at 22:54

























answered Dec 12 at 22:45









maarten

204




204












  • 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.
    – Doug Smythies
    Dec 12 at 23:16










  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12 at 23:56


















  • 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.
    – Doug Smythies
    Dec 12 at 23:16










  • Why is this so hard ? Can't figure out how to fix this permanently.
    – maarten
    Dec 12 at 23:56
















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.
– Doug Smythies
Dec 12 at 23:16




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.
– Doug Smythies
Dec 12 at 23:16












Why is this so hard ? Can't figure out how to fix this permanently.
– maarten
Dec 12 at 23:56




Why is this so hard ? Can't figure out how to fix this permanently.
– maarten
Dec 12 at 23:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1100474%2fdomains-resolving-to-public-ip-instead-of-local-ip-with-bind%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido