You are not logged in.

#1 2019-09-07 10:52:19

Duodai
Member
Registered: 2018-12-31
Posts: 2

[SOLVED] Network interfaces aliasing

Hi. I can not understand one place in Network configuration article. In particular, the sentence in bold from 'IP address aliasing' section:

Packets destined for a subnet will use the primary alias by default. If the destination IP is within a subnet of a secondary alias, then the source IP is set respectively. Consider the case where there is more than one NIC, the default routes can be listed with ip route.

How the source IP can be changed depending on interface alias? I thought it is an independent parameter. Perhaps there is a mistake and there should be 'destination IP is set respectively'. Can someone explain to me how it works?

Last edited by Duodai (2019-09-07 11:36:52)

Offline

#2 2019-09-07 11:19:54

the_clean
Member
From: USA
Registered: 2016-10-17
Posts: 16

Re: [SOLVED] Network interfaces aliasing

When you add an IP alias it is installed in the routing table but no routes are installed with it.  Meaning it is now active, but by default everything uses the primary IP address as a source when leaving the system (in my case wlp2s0 with IP address 10.10.10.104). Meaning, if the address is not known the default gateway would e the primary address, and so it writes the source IP as the 10.10.10.104 address and forwards it to the default gateway.  If however the destination for my secondary or alias IP address (wlp2s0:1 with IP address 192.168.1.101) it does a look up for the route to that address, sees there is an entry in the routing table for the 192.168.1.0 network and adds that source address to the IP SRC packet field and sends it out the same interface with a different source than the primary.  The lookup occurs before the IP header information is added to the packet for transmission.

EDIT:  I should add, if you are using two different addresses from the same network, the primary interface will always be the source unless you manipulate the source address for some or all destinations with the ip route command or iptables.

Last edited by the_clean (2019-09-07 11:23:25)

Offline

#3 2019-09-07 11:36:30

Duodai
Member
Registered: 2018-12-31
Posts: 2

Re: [SOLVED] Network interfaces aliasing

Oh, I assumed that the sentence was about incoming packets, not outgoing. Thank you for the detailed clarification.

Offline

Board footer

Powered by FluxBB