0

I am a networking newb - ping cannot locate certain dns names, so I put them in /etc/hosts like this:

10.128.0.22 kafka.marathn.meso
10.128.0.31 elasticsearch.marathn.meso

and then ping can find them. Is there a more dynamic/scalable way to map the DNS names to an IP address, in case the IP address changes?

4
  • hosts is fine. Assuming this is your network you can give the machines static addresses, dhcp reservations, or run your own dhcp && dns server which seems way overkill for your problem (but would be a good learning exercise). Commented Jan 30, 2020 at 21:06
  • right if the ips change, I will have to manually update /etc/hosts, I am looking for a way to resolve it automatically? Commented Jan 30, 2020 at 21:12
  • You should provide more information about how the IPs are assigned. Normally IP addresses are assigned by a home router running a DHCP server. The DHCP server can assign static IP addresses based on MAC (hardware) address. The router is often also running a DNS server, and it may be possible to configure it to resolve hostnames associated with its DHCP static IP mappings.
    – sjy
    Commented Jan 30, 2020 at 23:40
  • Please don't multi-post
    – Jeff Schaller
    Commented Feb 4, 2020 at 15:39

1 Answer 1

2

If this is a home lab, I would recommend setting up a DNS/DHCP server for a good learning exercise, as mentioned in the comment above by user1794469. This way, anytime the ip address is changed, the DNS record would be updated dynamically. The most important thing to do after that is to configure your client machines to point to your DNS server first, before they look else where.

DNS and DHCP were created to solve this exact problem. If you setup JUST a DNS server, you would still have to manually update the records anytime you add a new machine or a machine gets a different IP.

When you setup DNS and DHCP, the DHCP daemon will "Dynamically" update the records.

There are plenty of guides online for setting this up so make sure you find a guide for your choice of Linux distro

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .