0

For communication with machines in the same LAN, hosts do ARP for translating the IP address to MAC address, which means, IP addresses are already known to each other. My question is, how does the host come to know about the IP addresses of each other in the first place?

1
  • 1
    Most applications use DNS names that are resolved to IP addresses. However, applications and protocols above the transport layer are explicitly off-topic here, see the help center.
    – Zac67
    Oct 9 at 9:35
2

Most often, hosts use DNS to get the IP address from the host name.

2
  • Does DNS work only within LAN boundary? Also, if some protocol like DNS offers to share the IP address of some host, is there any reason, why MAC address can not be shared in the same response as well? Oct 9 at 9:21
  • 2
    @Network_starter DNS is an application-layer protocol (off-topic here) that works globally. MAC addresses are only meaningful within an L2 segment, so propagating them outside is useless.
    – Zac67
    Oct 9 at 9:37
2

Some application on one hosts needs to communicate with an application on another host. Either the IP address of that other host is configured in the application, or DNS is used to look up the IP address of a name (for example www.example.com is converted 192.0.2.123).

5
  • Okay. But, I am considering the case, where destination IP address is not pre-configured in this host. in such cases, is it always DNS or some other mechanism is also possible? Also, is this DNS same as mdns? Oct 9 at 9:27
  • 2
    Some application must initiate traffic to a specific destination, and that application either knows a hostname or an IP address where to send that traffic to mDNS can be used to discover which hosts are available on the network and thus used to convert a hostname into an IP address.
    – Teun Vink
    Oct 9 at 9:29
  • Okay, got it. But, one doubt is, if mDNS is used to learn about hosts and their IP addresses, it means, those hosts must have registered their host name and IP address in some server, so that, any mDNS query can send the reply back. If this is correct, why not those host also register their MAC addresses as well during the registration, so that, ARP broadcast may be avoided? Am I missing something? Oct 9 at 9:37
  • 2
    @Network_starter mDNS and DNS are different application-layer protocols (all off-topic here) albeit for the same purpose.
    – Zac67
    Oct 9 at 9:38
  • 1
    Is your real question “why use IP if you have MAC addresses?”
    – Ron Trunk
    Oct 9 at 17:06
0

if host A needs to communicate with host B, host A needs to know host's B address. It may be not an MAC or IP address, but it needs to be some address.

One common pattern is DNS, as described in other examples. Host B has a name. A network is running a service that allows to map host B's name to its current address. Important here is that (1) A has to know B's name, which btw can also be considered an address and (2) A knows how to reach DNS service, so A somehow knows its address.

There is a different available model, which is based on the concept of services. Services are some functions that can be performed by hosts/other network components. Some hosts provide services (aka are service providers). If other hosts want to use a service, they do service lookups which returns IP addresses of hosts(s) which provide the service. It can work other way around, each service provider periodically announses that it provides a service.

Service announcements and service lookups usually work by having well-known broadcast/multicast addresses for services. Service providers periodically broadcast announcement messages. Host, who lookup services, send discovery messages to well-known multicast addresses (and hope for reply :)). Examples of such a services are DHCP and IPv6 stateless address autoconfiguration.

Here is a wikipedia article for this. It has a couple of links with info. There is a mechanism called DNS-SD that allows to use DNS records for this. I think Multicast-DNS works like this too. And it has a couple of useful links.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.