Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

list Table of Contents
file_download PDF
keyboard_arrow_right

Example: Configuring the ICMP Protocol for Discovering Gateways to Other Networks

date_range 19-Feb-21

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.

Requirements

This example assumes that a server or a client computer on the local network supports RFC 1256, ICMP Router Discovery Messages.

Overview

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 224.0.0.2. Routers on the local network that support RFC 1256 immediately respond with a router advertisement.

The all-routers IP multicast address, 224.0.0.2, is the local IP broadcast address that IPv4 reserved. IPv4 multicast addresses in the range 224.0.0.0/24 (from 224.0.0.0 to 224.0.0.255) 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.

Note:

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.

content_copy zoom_out_map
[edit]
protocols {
    router-discovery;
}

To configure a router as a server for ICMP router discovery, you can include the following statements in the configuration:

content_copy zoom_out_map
[edit]
protocols {
    router-discovery {
        disable;
        address address {
            (advertise | ignore);
            (broadcast | multicast);
            (ineligible | priority number);
        }
        interface interface-name {
            lifetime seconds;
            max-advertisement-interval seconds;
            min-advertisement-interval seconds;
        }
        traceoptions {
            file filename <files number> <size size> <world-readable | no-world-readable>;
            flag flag <detail> <disable>;
        }
    }
}

Topology

Figure 1 shows a simplified sample topology.

Figure 1: ICMP Router Discovery TopologyICMP Router Discovery Topology

Configuration

Procedure

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 [edit] hierarchy level.

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 6 description to-R2
set interfaces ge-1/2/0 unit 6 family inet address 10.0.0.6/24
set protocols router-discovery traceoptions file icmp-log
set protocols router-discovery traceoptions flag all
set protocols router-discovery interface ge-1/2/0.6 max-advertisement-interval 60
set protocols router-discovery interface ge-1/2/0.6 min-advertisement-interval 10
set protocols router-discovery interface ge-1/2/0.6 lifetime 120
set protocols router-discovery address 10.0.0.6 multicast
set protocols router-discovery address 10.0.0.6 priority 900

Step-by-Step Procedure

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 Junos OS CLI User Guide.

To configure ICMP router discovery:

  1. Configure the network interfaces.

    This example shows multiple loopback interface addresses to simulate attached networks.

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set ge-1/2/0 unit 6 description to-R2
    user@R1# set ge-1/2/0 unit 6 family inet address 10.0.0.6/24
    
  2. Enable router discovery.

    content_copy zoom_out_map
    [edit protocols]
    user@R1# set router-discovery
    
  3. (Optional) Enable trace operations for router discovery.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set traceoptions file icmp-log
    user@R1# set traceoptions flag all
    
  4. (Optional) Set the IRDP maximum interval between advertisements.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set interface ge-1/2/0.6 max-advertisement-interval 60
    
  5. (Optional) Set the IRDP minimum interval between advertisements.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set interface ge-1/2/0.6 min-advertisement-interval 10
    
  6. (Optional) Set the IRDP period for which advertisements are valid.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set interface ge-1/2/0.6 lifetime 120
    
  7. (Optional) Configure the router to include the 10.0.0.6 IP address in IRDP advertisements to the all-hosts multicast address (224.0.0.1).

    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.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set address 10.0.0.6 multicast
    
  8. (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.

    content_copy zoom_out_map
    [edit protocols router-discovery]
    user@R1# set address 10.0.0.6 priority 900
    

Results

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.

content_copy zoom_out_map
user@R1# show interfaces
ge-1/2/0 {
    unit 6 {
        description to-R2;
        family inet {
            address 10.0.0.6/24;
        }
    }
}
content_copy zoom_out_map
user@R1# show protocols
router-discovery {
    traceoptions {
        file icmp-log;
        flag all;
    }
    interface ge-1/2/0.6 {
        max-advertisement-interval 60;
        min-advertisement-interval 10;
        lifetime 120;
    }
    address 10.0.0.6 {
        multicast;
        priority 900;
    }
}

If you are done configuring the device, enter commit from configuration mode.

Verification

Confirm that the configuration is working properly.

Checking the Trace Log

Purpose

Verify that the expected interfaces are sending messages.

Action

From operational mode, enter the show log icmp-log command.

content_copy zoom_out_map
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

Meaning

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.

external-footer-nav