Example: Configuring the ICMP Protocol for Discovering Gateways to Other Networks
This example shows how to configure Internet Control Message Protocol (ICMP) router advertisements to allow IPv4 hosts to discover the addresses of operational routers on the subnet. Hosts must discover routers before they can send IP datagrams outside their subnet.
This example assumes that a server or a client computer on the local network supports RFC 1256, ICMP Router Discovery Messages.
Before a host is able to send a message to a host outside its own subnet, it must be able to identify the address of the immediate router. This is typically done through reading a configuration file upon startup, and on some multicast networks by listening to routing protocol traffic. When a server or a client computer on the local network that supports RFC 1256 needs to locate a default gateway (router), the server or client computer uses ICMP to send a router solicitation. Hosts that support RFC 1256 send an ICMP router discovery message on the multicast address 188.8.131.52. Routers on the local network that support RFC 1256 immediately respond with a router advertisement.
The all-routers IP multicast address, 184.108.40.206, is the local IP broadcast address that IPv4 reserved. IPv4 multicast addresses in the range 220.127.116.11/24 (from 18.104.22.168 to 22.214.171.124) are reserved for the local subnet.
The ICMP Router Discovery Protocol (IRDP) uses router advertisements as well as router solicitation messages to allow hosts to learn the IP addresses of the router that is attached to the immediate network. When a host is started, it sends router solicitation messages to check for the address of the immediate router.
Not all hosts perform router discovery using the method specified in RFC 1256. If the host has DHCP enabled, it might not use ICMP router discovery. The performance of router discovery is one of the DHCP options that is defined in RFC 1541, Dynamic Host Configuration Protocol. This option specifies whether the client solicits routers using the ICMP router discovery method specified in RFC 1256. A value of 1 indicates that the client performs router discovery. A value of 0 indicates that the client does not.
To configure the router to be a router discovery server, you must include at least the following statement in the configuration. All other router discovery configuration statements are optional.
To configure a router as a server for ICMP router discovery, you can include the following statements in the configuration:
Figure 1 shows a simplified sample topology.
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the  hierarchy level.
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure ICMP router discovery:
- Configure the network interfaces.
This example shows multiple loopback interface addresses to simulate attached networks.[edit interfaces]user@R1# set ge-1/2/0 unit 6 description to-R2user@R1# set ge-1/2/0 unit 6 family inet address 10.0.0.6/24
- Enable router discovery.[edit protocols]user@R1# set router-discovery
- (Optional) Enable trace operations for router discovery.[edit protocols router-discovery]user@R1# set traceoptions file icmp-loguser@R1# set traceoptions flag all
- (Optional) Set the IRDP maximum interval between advertisements. [edit protocols router-discovery]user@R1# set interface ge-1/2/0.6 max-advertisement-interval 60
- (Optional) Set the IRDP minimum interval between advertisements.[edit protocols router-discovery]user@R1# set interface ge-1/2/0.6 min-advertisement-interval 10
- (Optional) Set the IRDP period for which advertisements
are valid. [edit protocols router-discovery]user@R1# set interface ge-1/2/0.6 lifetime 120
- (Optional) Configure the router to include the 10.0.0.6
IP address in IRDP advertisements to the all-hosts multicast address
If the router supports IP multicast, and if the interface supports IP multicast, multicast is the default. Otherwise, the addresses are included in broadcast router advertisement packets.[edit protocols router-discovery]user@R1# set address 10.0.0.6 multicast
- (Optional) Set the preference of the address to become
a default router.
This preference is set relative to the preferences of other router addresses on the same subnet.[edit protocols router-discovery]user@R1# set address 10.0.0.6 priority 900
From configuration mode, confirm your configuration by entering the show interfaces and show protocols commands. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.
If you are done configuring the device, enter commit from configuration mode.
Confirm that the configuration is working properly.
Checking the Trace Log
Verify that the expected interfaces are sending messages.
From operational mode, enter the show log icmp-log command.
user@R1> show log icmp-log
Mar 21 14:42:54 trace_on: Tracing to "/var/log/icmp-log" started Mar 21 14:42:54.409027 rdisc_ifa_change: Preference for address 10.0.0.6(ge-1/2/0.6) set to 900 Mar 21 14:43:33.983695 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 22 at 14:43:16 Mar 21 14:43:33.984263 rdisc_server_timer: group ge-1/2/0.6 timer set to 22 Mar 21 14:43:55.985225 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 37 at 14:44:10 Mar 21 14:43:55.985520 rdisc_server_timer: group ge-1/2/0.6 timer set to 37 Mar 21 14:44:32.986407 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 39 at 14:44:44 Mar 21 14:44:32.986961 rdisc_server_timer: group ge-1/2/0.6 timer set to 39 Mar 21 14:45:11.987331 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 10 at 14:44:42 Mar 21 14:45:11.987888 rdisc_server_timer: group ge-1/2/0.6 timer set to 10 Mar 21 14:45:21.990974 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 23 at 14:45:34 Mar 21 14:45:21.991548 rdisc_server_timer: group ge-1/2/0.6 timer set to 23 Mar 21 14:45:44.992150 task_timer_uset: timer RouterDiscoveryServer_Group <Touched Processing> set to offset 45 at 14:46:06 Mar 21 14:45:44.992710 rdisc_server_timer: group ge-1/2/0.6 timer set to 45
The log output shows that the preference was set to 900 for IP address 10.0.0.6 and that messages are being sent on the ge-1/2/0.6 interface.