cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
503
Views
0
Helpful
7
Replies

Routing

adityamysore17
Level 1
Level 1

How does a host connected to a router know the IP address of the router?This IP address will be used by the ARP to get the MAC address of the router.

Also how does a router know the MAC address or as a matter of fact the IP address of the next hop?

2 Accepted Solutions

Accepted Solutions

Yes the PC will be able to learn the mac as well as the ip address once the PC is able to reach the default gateway (Router ip address) and the same you can verify in your PC using below command

arp -a

Well, the PC will not know anything automatically unless it's able to communicate with the default gateway.


Lets say that PC has below configuration set

ip - 10.1.1.10
subnet mask - 255.255.255.0

Router has ip as 10.1.1.1 on its lan interface connecting to PC.

Then when you ping 10.1.1.1 from your PC it will be able to ping 10.1.1.1 although you did not set it as default gateway as both these are in same network. Once its able to ping, the arp and mac will be learnt by the PC automatically and stored in the arp table of PC and vice versa.

View solution in original post

So my question is how the PC gets the IP address of the router?

Commonly, if host is a IPv4 DHCP client, the gateway IP is provided as part DHCP information.

If host is not a IPv4 DHCP client, commonly the gateway IP is manually coded on the host.

For IPv6, router may advertise itself to hosts.

Also for IPv4, there's IRDP, another way for router to advertise itself.

Lastly, router can act as proxy.  To the client, client ARPs for destination IP and it receives router's MAC for IPs not on local network.

View solution in original post

7 Replies 7

Raja_D
Level 1
Level 1

The ip address of the host can be statically configured or the router can be configured as DHCP so that when a DHCP request for ip address is broadcasted from PC it will reach the router and the router will relay an ip address from the ip pool range that is set on the router.

Router checks the destination address of the packet in the routing table, to send the packet to that particular address!


When the PC sends a broadcast packet it would be received on the router and the router maintains the arp table in it which in turn will respond to the arp request for which the request was received and would respond to it.

You can use the command "show ip arp" which would give the output of the mac address learnt and the ip relating to it and the port details of the router interface through which the mac was learnt by the router.

Hi James,

Thanks for your answer. But I don't seem to have got the answer for my question. Are you saying that when a PC sends a broadcast packet, it learns both the IP and the MAC of the router?

If a host has to send a packet to another PC on some other network it has to pass through a router first. But to send the packet TO THE ROUTER, the PC needs to learn the IP Address and the MAC Address of the router. So my question is how the PC gets the IP address of the router?

I'm new to networking. So, need some extra help out here.

Thanks.

Yes the PC will be able to learn the mac as well as the ip address once the PC is able to reach the default gateway (Router ip address) and the same you can verify in your PC using below command

arp -a

Well, the PC will not know anything automatically unless it's able to communicate with the default gateway.


Lets say that PC has below configuration set

ip - 10.1.1.10
subnet mask - 255.255.255.0

Router has ip as 10.1.1.1 on its lan interface connecting to PC.

Then when you ping 10.1.1.1 from your PC it will be able to ping 10.1.1.1 although you did not set it as default gateway as both these are in same network. Once its able to ping, the arp and mac will be learnt by the PC automatically and stored in the arp table of PC and vice versa.

Thanks for your answer James. The example sure helped.

So my question is how the PC gets the IP address of the router?

Commonly, if host is a IPv4 DHCP client, the gateway IP is provided as part DHCP information.

If host is not a IPv4 DHCP client, commonly the gateway IP is manually coded on the host.

For IPv6, router may advertise itself to hosts.

Also for IPv4, there's IRDP, another way for router to advertise itself.

Lastly, router can act as proxy.  To the client, client ARPs for destination IP and it receives router's MAC for IPs not on local network.

Thanks for the answer Joseph. I didn't go through DHCP initially and ended up with a doubt. 

You are right. The host gets the IP of the router as part of the DHCP.

Joseph W. Doherty
Hall of Fame
Hall of Fame

Also how does a router know the MAC address or as a matter of fact the IP address of the next hop?

Router can ARP for MAC, although I think I recall (?) if network is p2p, it doesn't need next hop MAC for some p2ps.

As to how router know what's the next hop IP, it would know if from something like a static route statement or learn if from a dynamic routing protocol.  Remember a next hop address is for a set of destination networks.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco