[GH-ISSUE #107] Hostname for the host machine IP #46

Closed
opened 2026-02-26 04:33:53 +03:00 by kerem · 8 comments
Owner

Originally created by @ghost on GitHub (Mar 17, 2019).
Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/107

Originally assigned to: @mageddo on GitHub.

Hi,

I'm using dns-proxy-server for a docker app development. I need to resolve the host machine IP by hostname. I know how to achieve it using host.docker, but I'm using a connector that I can't modify which is using my hostname.

So, is there any way to resolve my hostname to 127.0.1.1? Linking the dns proxy server to /etc/hosts or something like that.

Maybe it can be already achieved, but I can't do it reading the docs, http://mageddo.github.io/dns-proxy-server/ :S

Thanks!!

Originally created by @ghost on GitHub (Mar 17, 2019). Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/107 Originally assigned to: @mageddo on GitHub. Hi, I'm using dns-proxy-server for a docker app development. I need to resolve the host machine IP by hostname. I know how to achieve it using host.docker, but I'm using a connector that I can't modify which is using my hostname. So, is there any way to resolve my hostname to 127.0.1.1? Linking the dns proxy server to /etc/hosts or something like that. Maybe it can be already achieved, but I can't do it reading the docs, http://mageddo.github.io/dns-proxy-server/ :S Thanks!!
kerem 2026-02-26 04:33:53 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@mageddo commented on GitHub (Mar 17, 2019):

@ncapilla Not sure if you already tried and didn't achieve your objective but DPS have a local storage where you can create hostname entries (A DNS records)

You can access the GUI by http://localhost:5380 or http://dns.mageddo, configure a new hostname that solves to 127.0.1.1 then you're done.

The GUI will create a new hostname entry at the config.json see this page

Update
I realized that you wanna set the host IP the machine hostname not 127.0.1.1

Today it's not possible, I think we can make the hostname name be customizable, not fixed on host.docker or implement #82

<!-- gh-comment-id:473664016 --> @mageddo commented on GitHub (Mar 17, 2019): @ncapilla Not sure if you already tried and didn't achieve your objective but DPS have a local storage where you can create hostname entries (A DNS records) You can access the GUI by http://localhost:5380 or http://dns.mageddo, configure a new hostname that solves to 127.0.1.1 then you're done. The GUI will create a new hostname entry at the config.json [see this page](http://mageddo.github.io/dns-proxy-server/docs/running.html#configure-your-dns) **Update** I realized that you wanna set the host IP the machine hostname not 127.0.1.1 Today it's not possible, I think we can make the hostname name be customizable, not fixed on `host.docker` or implement #82
Author
Owner

@mageddo commented on GitHub (Mar 17, 2019):

The issue here is that Linux solve hostnames looking at /etc/hosts before, then it try to solve using DNS server, so if you have some entry on your hosts file with machine hostname then DPS resolution will be discarded

Consider temporarily comment them

<!-- gh-comment-id:473664573 --> @mageddo commented on GitHub (Mar 17, 2019): The issue here is that Linux solve hostnames looking at /etc/hosts before, then it try to solve using DNS server, so if you have some entry on your hosts file with machine hostname then DPS resolution will be discarded Consider temporarily comment them
Author
Owner

@ghost commented on GitHub (Mar 17, 2019):

When I execute "nslookup $HOSTNAME" it resolve to 127.0.1.1, but once dns-proxy-server started it stops resolving my hostname. And it should use the /etc/hosts file first...

I'm missing something, I'll check out my ubuntu config.

Update
Adding my hostname to the config.json is a valid workaround for my local machine. But I'm running this setup on multiple environment so I need to do it dinamically :s

Update 2
If I comment the line "nameserver 127.0.0.53" in the /etc/resolv.conf file, then "nslookup $HOSTNAME" stops resolving localhost. So when I start dns-proxy-server and this line get commented it also stop working.

<!-- gh-comment-id:473707323 --> @ghost commented on GitHub (Mar 17, 2019): When I execute "nslookup $HOSTNAME" it resolve to 127.0.1.1, but once dns-proxy-server started it stops resolving my hostname. And it should use the /etc/hosts file first... I'm missing something, I'll check out my ubuntu config. **Update** Adding my hostname to the config.json is a valid workaround for my local machine. But I'm running this setup on multiple environment so I need to do it dinamically :s **Update 2** If I comment the line "nameserver 127.0.0.53" in the /etc/resolv.conf file, then "nslookup $HOSTNAME" stops resolving localhost. So when I start dns-proxy-server and this line get commented it also stop working.
Author
Owner

@ghost commented on GitHub (Mar 17, 2019):

Is it possible to ask the local dns server after trying the other ones?

As your documentation points out, first it finds a match at docker containers, second at local db, then it try to look at 8.8.8.8. What about a final step asking to local dns server?

Update

I've tried this config but it doesn't work as I expected.

{
"remoteDnsServers": [ [172,19,0,1] ],
"envs": [
{
"name": ""
}
],
"activeEnv": "",
"lastId": 0,
"webServerPort": 0,
"dnsServerPort": 0,
"defaultDns": null,
"logLevel": "",
"logFile": "",
"registerContainerNames": null
}

<!-- gh-comment-id:473713473 --> @ghost commented on GitHub (Mar 17, 2019): Is it possible to ask the local dns server after trying the other ones? As your documentation points out, first it finds a match at docker containers, second at local db, then it try to look at 8.8.8.8. What about a final step asking to local dns server? **Update** I've tried this config but it doesn't work as I expected. { "remoteDnsServers": [ [172,19,0,1] ], "envs": [ { "name": "" } ], "activeEnv": "", "lastId": 0, "webServerPort": 0, "dnsServerPort": 0, "defaultDns": null, "logLevel": "", "logFile": "", "registerContainerNames": null }
Author
Owner

@mageddo commented on GitHub (Mar 18, 2019):

Is it possible to ask the local dns server after trying the other ones?

A local entry inside your config.json will not work cause DPS is running inside docker container, it can't listen to local DNS server

You can define multiple nameservers at your /etc/resolv.conf

If I comment the line "nameserver 127.0.0.53" in the /etc/resolv.conf file, then "nslookup $HOSTNAME" stops resolving localhost. So when I start dns-proxy-server and this line get commented it also stop working.

This sound very strange for me, I thought resolv.conf wasn't necessary to solve hosts file hostnames.

Adding my hostname to the config.json is a valid workaround for my local machine. But I'm running this setup on multiple environment so I need to do it dinamically :s

I see, I think make host machine hostname be configurable is not a big change, I will consider develop it in the next days

<!-- gh-comment-id:473887927 --> @mageddo commented on GitHub (Mar 18, 2019): > Is it possible to ask the local dns server after trying the other ones? A local entry inside your config.json will not work cause DPS is running inside docker container, it can't listen to local DNS server You can define multiple nameservers at your /etc/resolv.conf > If I comment the line "nameserver 127.0.0.53" in the /etc/resolv.conf file, then "nslookup $HOSTNAME" stops resolving localhost. So when I start dns-proxy-server and this line get commented it also stop working. This sound very strange for me, I thought resolv.conf wasn't necessary to solve hosts file hostnames. > Adding my hostname to the config.json is a valid workaround for my local machine. But I'm running this setup on multiple environment so I need to do it dinamically :s I see, I think make host machine hostname be configurable is not a big change, I will consider develop it in the next days
Author
Owner

@ghost commented on GitHub (Mar 18, 2019):

I finally found the error, the connector is listening on a port in the host machine. Then a container is trying to open a connection to the host machine using its hostname.
So, It isn't a problem with the dns-proxy-server...

Anyway making host machine hostname configurable is a nice feature to consider ;)

Thanks for your help!!

<!-- gh-comment-id:473888644 --> @ghost commented on GitHub (Mar 18, 2019): I finally found the error, the connector is listening on a port in the host machine. Then a container is trying to open a connection to the host machine using its hostname. So, It isn't a problem with the dns-proxy-server... Anyway making host machine hostname configurable is a nice feature to consider ;) Thanks for your help!!
Author
Owner

@mageddo commented on GitHub (Mar 31, 2019):

Feature was developed, please check the release notes.

Be aware if you set the host machine hostname as the machine name then you will have to remove
it's name from /etc/hosts since OS try to resolve names from hosts file first
then from DNS server

<!-- gh-comment-id:478348614 --> @mageddo commented on GitHub (Mar 31, 2019): Feature was developed, please check the [release notes](https://github.com/mageddo/dns-proxy-server/releases/tag/2.11.0). Be aware if you set the host machine hostname as the machine name then you will have to remove it's name from `/etc/hosts` since OS try to resolve names from hosts file first then from DNS server
Author
Owner

@mageddo commented on GitHub (Mar 31, 2019):

Feel free to comment if you wish to discuss about anything related to this issue

<!-- gh-comment-id:478348711 --> @mageddo commented on GitHub (Mar 31, 2019): Feel free to comment if you wish to discuss about anything related to this issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dns-proxy-server-mageddo#46
No description provided.