Setting an IP Address for the Router

Problem

You want to assign an address to the router itself so that you can reach it at all times, even when a particular interface is not available and so that applications such as SNMP can always reach the router.

Solution

Use the following command to configure a permanent address for the router:

	[edit]
	aviva@RouterA# set interfaces lo0 unit 0 family inet address 192.168.16.1/32

 

Discussion

Most of the IP addresses you configure on a router are for physical network interfaces, such as an Ethernet or T1 interface. While these interfaces are generally present and operating in the router, you don't want to use them to find out the status of the router, because someone might remove the PIC from the router or because the physical interface may not be up or may not be configured properly even though the router is up and running fine. The solution is to configure an IP address that uniquely identifies your router. You do this by configuring the lo0, or loopback, address.

In the JUNOS software, the loopback address is named lo0. This name doesn't follow the standard JUNOS interface naming conventions. It is just the same name as the Unix loopback interface. You don't need to specify a PIC, FPC, or slot number because the loopback address is not associated with hardware, but is just an internal address on the router. You configure the loopback address on logical unit 0, and the address is an IPv4 address (set with the keyword inet). In this recipe, we set the loopback address to 192.168.16.1/32.

The loopback address on a JUNOS router is used as the IP address of the router itself and is similar to the Unix localhost, which is the address of the local system. The JUNOS software uses this address when it needs to talk to itself using IP.

To see that the loopback address has been configured, you can look at its status:

	aviva@RouterA> show interfaces lo0
	Physical interface: lo0, Enabled, Physical link is Up
	 Interface index: 6, SNMP ifIndex: 6
	 Type: Loopback, MTU: Unlimited
	 Device flags : Present Running Loopback
	 Interface flags: SNMP-Traps
	 Link flags : None
	 Last flapped : Never
	 Input packets : 19
	 Output packets: 19

	 Logical interface lo0.0 (Index 69) (SNMP ifIndex 16)
	 Flags: SNMP-Traps Encapsulation: Unspecified
	 Input packets : 0
	 Output packets: 0
	 Protocol inet, MTU: Unlimited
	 Flags: None
	 Addresses, Flags: Is-Default Is-Primary
	 Local: 192.168.16.1

	 Logical interface lo0.16385 (Index 64) (SNMP ifIndex 21)
	 Flags: SNMP-Traps Encapsulation: Unspecified
	 Input packets : 5
	 Output packets: 5
	 Protocol inet, MTU: Unlimited
	 Flags: None
	 Addresses, Flags: Is-Default Is-Primary
	 Local: 10.0.0.1
	 Addresses
	 Local: 10.0.0.16

You see the loopback interface address in the logical interface portion of the output. You can see that the lo0 interface is operational (from the Present and Running device flags) and that it is a loopback interface (from the Loopback device flag) with an unlimited MTU size. SNMP traps are enabled on the router, no link flags are set (these flags are only for network interfaces, which lo0 is not), and the interface has never gone down and come back up (flapped). The input and output fields show the number of packets that have passed through the interface. One interesting thing to notice is the existence of logical interface lo0.16385. This is a nonconfigurable interface created by the JUNOS software for routing platform control traffic. The two addresses shown for this logical interface are used internally.

Because the address is just an address for the router and is not used for a software loopback mechanism, it can be any /32 address. You are not limited to using the standard loopback address of 127.0.0.1. Some JUNOS applications, including NTP, RADIUS, TACACS+, and SSL for the JUNOScript API, require a loopback address of 127.0.0.1. You either can set this as your primary loopback address or can configure multiple loopback addresses:

	[edit]
	aviva@RouterA# set interfaces lo0 unit 0 family inet address 192.168.16.1/32
	aviva@RouterA# set interfaces lo0 unit 0 family inet address 127.0.0.1/32

You see that this address is configured, but is not the default or primary address:

	aviva@RouterA# run show interfaces lo0.0
	 Logical interface lo0.0 (Index 69) (SNMP ifIndex 16)
	 Flags: SNMP-Traps Encapsulation: Unspecified
	 Input packets : 0
	 Output packets: 0
	 Protocol inet, MTU: Unlimited
	 Flags: None
	 Addresses
	 Local: 127.0.0.1
	 Addresses, Flags: Is-Default Is-Primary
	 Local: 192.168.42.1

 

See Also

Recipes 7.1 and 7.10


Router Configuration and File Management

Basic Router Security and Access Control

IPSec

SNMP

Logging

NTP

Router Interfaces

IP Routing

Routing Policy and Firewall Filters

RIP

IS-IS

OSPF

BGP

MPLS

VPNs

IP Multicast



JUNOS Cookbook
Junos Cookbook (Cookbooks (OReilly))
ISBN: 0596100140
EAN: 2147483647
Year: 2007
Pages: 290
Authors: Aviva Garrett

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net