Virtual-Hosts
Virtual-Hosts copied to clipboard
Switch to map hostnames with local IPs automatically
Scenario
I have some devices visible on network. DNS lookup gives bunch of information including hostname and IP address of each device.
Current behavior vs required behavior
- Current:
- We manually enter the device to hostname mapping in hosts and use the file
- Task:
- Automatically make an FQDN out of the device hostname (perhaps added a .local at the end)
Benefits
This will eliminate the effort to manually map the entries.
Example
LAN Scan
- Lenovo-PC --> 192.168.43.5
- HP --> 192.168.43.18
Mappings
- Lenovo-pc.local --> 192.168.43.5
- hp.local --> 192.168.43.18 (Not case sensitive)
Proof of concept
- Every hostname on a network must be unique. This makes it possible to map every hostname with an IP without any problems.
- I know this is programmatically possible because Net analyzer and many other apps on Google play already do a LAN scan and print this information to screen. What we need to do here is take this information, append a suffix (like .local) and make a dynamic hosts out of it.
Challenges
Devices can come into the network at any point of time. Auto-refreshing the hosts file can be a bit of challenge (perhaps battery consuming as well?). Devices moving out of network should not be a problem as anything connecting will automatically give a timeout.