On Tue, 16 Apr 2019 11:03:14 -0400 Celejar <cele...@gmail.com> wrote:
> Hi, > > I've been bedeviled by this question for a while, but have been unable > to figure out a clean, non-hackish solution. It may be an XY problem ... > > I have a system (laptop, running Debian) that is sometimes connected > directly to my LAN, and sometimes connected via VPN (wireguard, to the > local router, running OpenWrt). The LAN is 192.168.0.0/24, with the > laptop having a fixed, static address in that range (although I'm > certainly open to using DHCP, possibly with a fixed address > reservation). The VPN is 10.0.0.0/24, with the laptop getting a fixed, > static address in that range (and wireguard apparently doesn't work > with dhcp). > > I currently have an entry in /etc/hosts on the various LAN hosts > assigning a hostname to the laptop's fixed local address, and the LAN > hosts can access the laptop via that hostname. [I could alternatively > use dnsmasq, which is running on the router regardless.] This obviously > doesn't work when the laptop is connected via VPN. [The laptop can > access the LAN hosts fine via their hostnames, so I seem to have the > routing correctly configured on the laptop and the router.] > > What I seem to want (but maybe XY?) is some way to adjust the host > files (or dnsmasq's information) so that the hostname will resolve to > the LAN address when the laptop is connected to the LAN, and the VPN > address when it's connected via VPN. If everything was using DHCP, this > would be straightforward enough, but as I said, the VPN apparently > needs to be configured statically, and not via DHCP. I could obviously > use some custom script (using, say, ageas, to modify host files) but > this seems hackish. What is a standard, 'correct' way to do this, or > more generally, to enable the LAN hosts to access the laptop > seamlessly regardless of its IP address and connection type? > > Celejar We had a long thread about this back in April [0], but no good solution was presented, so I decided to design a framework to address this problem. It's probably overkill, but it was a good opportunity to practice my Perl in general, and learn how to write a web application in particular. So FWIW, I give you 'dynhosts': https://github.com/tmo1/dynhosts [0] https://lists.debian.org/debian-user/2019/04/msg00725.html Celejar