28.06.2014 Views

Discussion

Discussion

Discussion

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7.4 Setting the Router’s Source Address<br />

Problem<br />

All IP traffic that is sourced from the router includes a source address in the IP<br />

header. The address chosen for packets depends on the interface that is used to reach<br />

the destination when the connection is established. You want to configure the router<br />

to used a fixed address.<br />

Solution<br />

Use the following command to always uses lo0 loopback address as the source<br />

address in IP packets:<br />

[edit]<br />

aviva@router1# set system default-address-selection<br />

<strong>Discussion</strong><br />

When selecting an address to include in the source address field of IP packets, the<br />

JUNOS software chooses from among the addresses configured on the router. The<br />

first candidate to use is the first non-127.0.0.1 address configured on the lo0 interface.<br />

However, this means that the software usually, but not always, chooses the<br />

loopback address. To ensure that the software always uses the router’s IP address,<br />

use the set system default-address-selection command. Including this command is<br />

considered good practice so that when other systems on the network receive traffic<br />

from the local router, the packets always have the same address in the IP packet’s<br />

source address field. This command forces the router to use one specific address, the<br />

lo0 address, for most of the traffic that originates from the router. The source<br />

address never affects traffic that is forwarded by the router, only packets that are<br />

sourced from the router. If multiple addresses are configured for lo0, the software<br />

chooses the one with the lowest address. However, if you assign the parameter<br />

primary or preferred to a higher IP address, the software uses the higher IP address.<br />

The following command makes one of the loopback addresses the primary one:<br />

[edit]<br />

aviva@RouterA# set interfaces lo0 unit 0 family inet address 192.168.16.1/32 primary<br />

Figure 7-1 illustrates why you should set the router’s source address. In this topology,<br />

if you ping 1.0.2.1 from Mars, Mars normally sends the packet out the so-0/0/0<br />

interface and uses 1.0.2.2 as the source address for that ping packet. Venus receives<br />

the ping and sends a response back to 1.0.2.2 (the source address).<br />

If Mars, Venus, and Earth have lo0 addresses 1.1.0.1/32, 1.1.0.2/32, and 1.1.0.3/32,<br />

and you have the default address selection configured on Mars, what happens is different.<br />

If you ping 1.0.2.1 from Mars, Mars uses 1.1.0.1 (its lo0 address) as the<br />

source address. It still sends the packet out so-0/0/0, and Venus still receives it and<br />

sends a response back to the source address of the ping, 1.1.0.1.<br />

204 | Chapter 7: Router Interfaces<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!