Choosing Primary and Preferred Interface Addresses

Problem

You have an Ethernet or other point-to-multipoint interface and have to set up multiple addresses on the interfacefor example, so you can treat class of service for each flow differentlybut you need to always use one of the addresses first.

Solution

Use the following commands to pick one address to always be the source address for traffic on the same subnet:

	[edit interfaces fe-0/0/0]
	aviva@router1# set unit 0 family inet address 192.168.220.1/24
	aviva@router1# set unit 0 family inet address 192.168.220.2/24 
preferred

Use the following commands to choose one address that is used as the source address in broadcast and unnumbered traffic sent out an interface:

	[edit interfaces fe-0/0/1]
	aviva@router1# set unit 0 family inet address 192.168.220.1/24
	aviva@router1# set unit 0 family inet address 192.168.220.2/24 
primary

 

Discussion

Each JUNOS interface has a preferred address, which is the default local address used when there is more than one address in the same subnet on the same interface. Each JUNOS interface also has a primary address, which is used by default as the source address when you originate packets out the interface where the destination gives no hint about the subnet. By default, the software chooses the numerically lowest address as the preferred and primary address. The show interfaces command output indicates which addresses are the preferred and primary:

	aviva@router1> show interfaces fe-0/0/0.0
	 Logical interface fe-0/0/0.0 (Index 66) (SNMP ifIndex 84)
	 Flags: SNMP-Traps Encapsulation: ENET2
	 Protocol inet, MTU: 1500
	 Flags: None
	  
Addresses, Flags: Is-Preferred Is- 
Primary
	 Destination: 192.168.220.0/24, Local: 192.168.220.1,
	 Broadcast: 192.168.220.3

Here we see that the address configured on the Fast Ethernet logical interface, 192.168.220.1/30, is both the preferred and primary address for the interface.

For some point-to-multipoint and other applications, you configure multiple address on a single logical interface:

	[edit interfaces fe-0/0/0]
	aviva@router1# set unit 0 family inet address 192.168.220.2/24
	aviva@router1# show
	unit 0 {
	 family inet {
	 address 192.168.220.1/24;
	 address 192.168.220.2/24;
	 }
	}

With this configuration, the first address continues to be the preferred and primary address because, numerically, it is the lower of the two:

	aviva@router1> show interfaces fe-0/0/0.0
	 Logical interface fe-0/0/0.0 (Index 66) (SNMP ifIndex 84)
	 Flags: SNMP-Traps Encapsulation: ENET2
	 Protocol inet, MTU: 1500
	 Flags: None
	 Addresses, Flags: Is-Preferred Is-Primary
	 Destination: 192.168.220.0/24, Local: 192.168.220.1,
	 Broadcast: 192.168.220.3
	 Addresses
	 Destination: 192.168.220.0/24, Local: 192.168.220.2,
	 Broadcast: 192.168.220.3

To have the higher address be the primary or preferred address, use the commands shown in the recipe:

	aviva@router1# show
	unit 0 {
	 family inet {
	 address 192.168.220.1/24;
	 address 192.168.220.2/24 {
	 primary;
	 preferred;
	 }
	 }
	}
	aviva@router1> show interfaces fe-0/0/0.0
	 Logical interface fe-0/0/0.0 (Index 66) (SNMP ifIndex 84)
	 Flags: SNMP-Traps Encapsulation: ENET2
	 Protocol inet, MTU: 1500
	 Flags: None
	 Addresses
	 Destination: 192.168.220.0/24, Local: 192.168.220.1,
	 Broadcast: 192.168.220.3
	  
Addresses, Flags: 
Primary 
Preferred Is-Preferred Is-Primary
	 Destination: 192.168.220.0/24, Local: 192.168.220.2,
	 Broadcast: 192.168.220.3

It's helpful to expand the configuration a bit to illustrate how the source addresses are used. Let's say we have:

	[edit interfaces fe-0/0/0 unit 0 family inet]
	address 192.168.220.1/24;
	address 192.168.220.2/24 {
	 primary;
	 preferred;
	}
	address 192.168.222.1/24;
	address 192.168.222.2/24 {
	 preferred;
	}

IP traffic bound for 192.168.220.10 uses 192.168.220.2 as the source address because this is the preferred address. Traffic for, say, 100.0.0.1 also uses 192.168.220.2 (if there is a route to that network pointing out fe-0/0/0) because this is the interface's primary address. Traffic for 192.168.222.10 uses 192.168.222.2 as the source address, again because this is the interface's preferred address.

Another situation is to have multiple addresses on the loopback interface, which you might want for any number of reasons. You might want a public address for the router's IP address, a private one for management access, and 127.0.0.1 as the traditional loopback address.

Yet another reason to have multiple address on an interface is to increase the number of IP addresses on an Ethernet network without renumbering devices that are already there. While this is often not considered good practice, sometimes it's the easiest way to deal with the growing number of addresses. Say you have interface fe-0/0/0 with IP address 205.134.233.254/24. When you've used all the addresses in that /24 address space, you can either renumber all 250 or so devices on that network, grow that network (which requires planning ahead; in this case you could just make the network a /23 if you're not using 205.134.232.0/24 for anything else), or just add another network. As an interim measure, you can just add the second address for the new network address space to the interface and set the desired one to be the primary and preferred address.


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