I have a Centos 5 box with a sub interface:
ifconfig eth0 10.1.1.1 255.255.255.255 ifconfig eth0:1 10.1.1.2 255.255.255.255
The netmasks need to be 32bit in the environment this server is in. So in order to specify the default route, we let the server know where the gateway is, and then default route to it:
Destination Gateway Genmask Flags MSS Window irtt Iface 10.1.1.10 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 0.0.0.0 10.1.1.10 0.0.0.0 UG 0 0 0 eth0
So 10.1.1.10 is the default gateway, and it is out interface eth0
However, all packets that leave the server have the IP address associated with eth0:1. They need to have the IP on eth0.
The routing is defined in route-eth0:
10.1.1.10/32 dev eth0 default via 10.1.1.10
And I have tried to force the issue with GATEWAY and SRCADDR in ifcfg-eth0:
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=10.1.1.1 SRCADDR=10.1.1.1 NETMASK=255.255.255.255 GATEWAY=10.1.1.10
No gateway is defined in ifcfg-eth0:1:
DEVICE=eth0:1 IPADDR=10.1.1.2 NETMASK=
The eth0 IP address is the one used for the fqdn in /etc/hosts. If I ping the fqdn, I get the eth0 IP address.
Could some let me know how I can force outgoing packets to use the IP bound to eth0 rather than the IP bound to eth0:1 as the source IP.