Overriding DNS in peer-peer fashion

1

I frequently have the problem that I am on a local network where DNS is done by routers I have no control over. I often want to send files or data between two of my devices on the same subnet, but they are assigned a random DHCP address on each connection.Hard-coding addresses, or setting preferred DHCP assignments doesn't seem to work, as a random address is assigned by the router anyway

I am looking for some kind of broadcast based DNS override, or synchronisation system. I am variously using Linux Mint 17 or debian testing.

Is there some package that I can install as a DNS "shim", which will allow the two machines to recognise each other and override their local DNS settings automagically? My current solution is to check the IP on each machine and have a script to update all the settings I need to change manually.

The system doesn't need to be secure, as I am using key based logins between the devices, where I have already shared the keys by copying the file via USB. Any attempt to MITM will be detected at the login stage.

Unfortunately my searching has not got the right combo of keywords to find anything relevant.

Thanks!

user425952

Posted 2015-03-08T11:48:46.320

Reputation: 13

Answers

0

Sounds like Avahi (Multicast DNS) could be what you’re looking for. In combination with nss-mdns, you can use its FQDN host names just like any other DNS host name. Packages should be available for just about every Linux distribution out there.

To enable nss-mdns, you need to edit /etc/nsswitch.conf so the hosts: line looks like this:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

After enabling both the Avahi daemon and nss-mdns, you should be able to connect to a machine with host name my-machine like this:

sftp my-machine.local

Daniel B

Posted 2015-03-08T11:48:46.320

Reputation: 40 502

Thanks - this seems to work locally, I don't have my second device on me right now. nss-mdns seems to be a plugin (libnss-mdns). The avahi documentation isn't great - no examples, or similar that I can find. Manpages are terse at best.

Thanks again for the advice! I'd looked at avahi, but hadn't understood how to use it.

I assume that for mdns to work, I need to enable it in nsswitch.conf on all devices, not just the one I want to be able to resolve from?

lastly, the .local seems to be compulsory. avahi-resolve wont resolve without it, even though its not part of the computer's host name. – user425952 – 2015-03-08T14:39:04.483

Generally, you don’t need to configure anything at all with Avahi. Except when you want to advertise services. About .local: It is part of the host name—the fully qualified host name. You need to edit nsswitch.conf only on devices where you want to be able to resolve host names from all programs. – Daniel B – 2015-03-08T16:09:35.687

0

If you're actually on the same subnet, why not alias the network interface and configure the alias with a static IP address that would be on the same subnet? Pick something completely different, so if they're using 10.0.0.0/8, use 192.168.0.0/24 or something. Assuming that peer to peer switching is enabled on the network edge that should just work. Assuming you're not wireless, of course. If you are wireless, can you set up an ad-hoc wireless network? Some network cards allow you to join multiple networks at once. Not sure if you can join an ad-hoc and a normal one at the same time, though.

Then you can just add the ip address of the other machine to the /etc/hosts file.

Bacon Bits

Posted 2015-03-08T11:48:46.320

Reputation: 6 125