[CentOS] Routing of outgoing packets

Mon Nov 22 00:23:33 UTC 2010
Rob Townley <rob.townley at gmail.com>

2010/10/1 Mitja Mihelič <mitja.mihelic at arnes.si>:
>
> On 09/30/2010 05:02 PM, John Doe wrote:
>> From: Mitja Mihelič<mitja.mihelic at arnes.si>
>>> I am trying to use hping to chek the latency of our network.
>>> Somehow things are not going to plan and I thought someone might be able
>>> to shed some light on the subject.
>>> Here is the setup:
>>> (the IP addresses gvien here are fake, but they do represent the correct
>>> state of the networking setup)
>>> vlan      interface      IP                      mask
>>> V2        eth0           192.168.20.20    32
>>> V4        eth1           172.16.4.40        32
>>> V6        eth2           172.16.6.60        32
>>>
>>> The default route is set to eth1.
>>> The idea is to use eth2 for pinging only, the other two interfaces are
>>> used by another service and management access.
>> Could you show the ifconfig and route outputs...?
>>
>> JD
> The Centos version is 5.5.
>
> This is the kernel we are using
> (http://rpms.mcnc.org/web100/el5/distro-compat/i386/):
> 2.6.18-164.15.1.el5.web100PAE #1 SMP Mon May 17 17:01:51 EDT 2010 i686
> athlon i386 GNU/Linux
>
> The IP addresses are presented as private addresses, netmasks are real.
>
> Here is the ifconfig output:
> [root at server ~]# ifconfig
> eth0      Link encap:Ethernet  HWaddr 00:16:35:82:45:A0
>           inet addr:192.168.254.236  Bcast:192.168.254.239
> Mask:255.255.255.240
>           inet6 addr: fe80::216:35ff:fe82:45a0/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:139602 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:58914 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:211203420 (201.4 MiB)  TX bytes:4285647 (4.0 MiB)
>           Interrupt:186 Memory:dc000000-dc012800
>
> eth1      Link encap:Ethernet  HWaddr 00:16:35:82:45:A2
>           inet addr:192.168.254.244  Bcast:192.168.254.247
> Mask:255.255.255.248
>           inet6 addr: fe80::216:35ff:fe82:45a2/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:15 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:1130 (1.1 KiB)  TX bytes:1116 (1.0 KiB)
>           Interrupt:194 Memory:da000000-da012800
>
> eth2      Link encap:Ethernet  HWaddr 00:15:17:C5:84:4D
>           inet addr:192.168.254.18  Bcast:192.168.254.23
> Mask:255.255.255.248
>           inet6 addr: fe80::215:17ff:fec5:844d/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:29 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:2280 (2.2 KiB)  TX bytes:1236 (1.2 KiB)
>           Memory:dfde0000-dfe00000
>
> lo        Link encap:Local Loopback
>           inet addr:127.0.0.1  Mask:255.0.0.0
>           inet6 addr: ::1/128 Scope:Host
>           UP LOOPBACK RUNNING  MTU:16436  Metric:1
>           RX packets:21 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:4240 (4.1 KiB)  TX bytes:4240 (4.1 KiB)
>
>
> And the route command output:
> [root at server ~]# route -n
> Kernel IP routing table
> Destination      Gateway          Genmask          Flags Metric Ref
> Use Iface
> 192.168.18.122   192.168.254.225  255.255.255.255  UGH   0      0
> 0 eth0
> 192.168.254.16   0.0.0.0          255.255.255.248  U     0      0
> 0 eth2
> 192.168.254.240  0.0.0.0          255.255.255.248  U     0      0
> 0 eth1
> 192.168.18.160   192.168.254.225  255.255.255.240  UG    0      0
> 0 eth0
> 192.168.254.224  0.0.0.0          255.255.255.240  U     0      0
> 0 eth0
> 192.168.1.64     192.168.254.225  255.255.255.192  UG    0      0
> 0 eth0
> 192.168.1.128    192.168.254.225  255.255.255.128  UG    0      0
> 0 eth0
> 169.254.0.0      0.0.0.0          255.255.0.0      U     0      0
> 0 eth2
> 0.0.0.0          192.168.254.241  0.0.0.0          UG    0      0
> 0 eth1
>
> --
> Mitja
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>

This may be too late, but came across this searching for my old
iproute conversations.
Each NIC needs its own "source based route" otherwise, it will use the
sytem wide default route.
In other words, add "nic specific default routes" in addition to the
"system wide default route".

Once you have nic specific source routes, you may notice a big
difference between the following two seemingly identical commands:
ping -I eth2 208.67.222.222
ping -I 192.168.x.y  208.67.222.222