You are not logged in.

#1 2014-05-11 14:56:06

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

[mostly sloved] Access a dnsmasq server (over ssh) by its hostname?

This is only a minor problem as I can access that dnsmasq-Server anytime by its IP, but anyway, I would be interested in knowing a solution for that:

I have a dnsmasq server with the hostname "server". When I try to access it by ssh by a computer using that DNS, the following happens:

ssh server
ssh: connect to host server port 22: Invalid argument

It's clear why that happens: Trying to ping server shows:

ping server
64 bytes from localhost.localdomain (127.0.0.1) ...

and that because of the /etc/hosts file of server:

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       localhost.localdomain   localhost   server
....

and as /etc/hosts is parsed by dnsmqasq, dnsmasq tells that "server" has 127.0.0.1.

So the analysis of the problem is clear, but what is the solution? (apart from accessing the dnsmasq Server by its IP, which is more typing...)
As far as I understand, I can't leave out that line in /etc/hosts , can I?

Last edited by Carl Karl (2014-05-13 05:56:19)

Offline

#2 2014-05-12 07:34:53

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: [mostly sloved] Access a dnsmasq server (over ssh) by its hostname?

Simply try adding the actual ip of the server to your /etc/hosts file. So that would become something among the lines of (replace 10.0.0.1 with the correct ip obviously):

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       localhost.localdomain   localhost   server
10.0.0.1        server

Burninate!

Offline

#3 2014-05-12 10:07:57

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [mostly sloved] Access a dnsmasq server (over ssh) by its hostname?

@ Gcool

same hostname cannot be assigned to multiple ips. I just tested it, and the one that appears at the start of the file takes precedence.

Offline

#4 2014-05-13 05:55:40

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [mostly sloved] Access a dnsmasq server (over ssh) by its hostname?

At least you can put it in the /etc/hosts of the computer you run the ssh client on. Good enough, as long as the number of clients is finite. ;-)
Also, it is possible to assign a second name for that server in its hosts file.

Both are good enough for me, thanks. :-)

Offline

#5 2014-05-13 15:30:13

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [mostly sloved] Access a dnsmasq server (over ssh) by its hostname?

This needs to be done in the dnsmsaq service itself.  http://wiki.openwrt.org/doc/howto/dhcp.dnsmasq?s[]=dns&s[]=hostname#configuring.dnsmasq.to.associate.client.hostnames.with.dhcp-supplied.ip.addresses  It is for openwrt, but the configuration in the example uses the dnsmasq.conf file rather than the uci interface/configs, so it should apply to whatever you are running dnsmasq on.

Edit: Sorry, the forums don't like the square brackets in the url and I don't feel like figuring out how fix it.

Last edited by WonderWoofy (2014-05-13 22:35:34)

Offline

Board footer

Powered by FluxBB