2

I have following four IPv4 addresses configured to eth0 interface:

# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:16:41:54:01:93 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.1/24 scope global eth0
    inet 192.168.2.2/30 scope global eth0
    inet 10.10.10.128/24 scope global secondary eth0
    inet 10.10.10.127/24 scope global secondary eth0
# 

Now if I send traffic to any(10.10.10.1, 192.168.2.2, 10.10.10.128 or 10.10.10.127) of those addresses from IP address 10.10.11.1, then despite the fact that I have specified the source IP to be 10.10.10.127:

# ip route show match 10.10.11.1
default via 192.168.2.1 dev eth0  src 10.10.10.127 
# 

..my machine sends out packets with the same source IP which was used as a destination IP, e.g. if I execute ping 10.10.10.128 source 10.10.11.1 in a remote machine, then my machine sends out replies with source address 10.10.10.128:

16:11:02.478607 00:19:e2:9e:ec:00 > 00:16:41:54:01:93, ethertype IPv4 (0x0800), length 114: 10.10.11.1 > 10.10.10.128: ICMP echo request, id 34, seq 4, length 80
16:11:02.478616 00:16:41:54:01:93 > 00:19:e2:9e:ec:00, ethertype IPv4 (0x0800), length 114: 10.10.10.128 > 10.10.11.1: ICMP echo reply, id 34, seq 4, length 80

In which situation src address specified in routing table has affect?

2

The system always responds to traffic with the address the traffic was sent to.

If you ping 10.10.10.128, and then receive response traffic from 10.10.10.127, your system is going to see this other traffic and discard it. Your system has no clue who 10.10.10.127 is, and why it's trying to talk to you.

However if the system that has both 10.10.10.127 and 10.10.10.128 on it tries to initiate communication with an another host, then it will use routing rules to determine the appropriate source address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.