3

I want to visit a site through assigned IP address. I run the following commands:

ifconfig eth0:1 [ip address]
route add -host [the target host ip] dev eth0:1 gw [gateway]

This works fine on Ubuntu. But when I want to do the same on a Redhat AS4 server, it doesn't work. ping works for the new IP address, but after running route, the target site can't be visited. Anyone know the reason?

2 Answers2

6

Last time I checked route wasn't "aware" of interface aliases. For route eth0:1 == eth0.

The solution is to use the ip route command:

ifconfig eth0:1 [ip address]
ip route add [the target host ip]/32 via [gateway] dev eth0 src [ip address]

This command should do the trick. Make sure you're not using iptables MASQUERADE on the interface, it seems to conflict with these things.

Etienne Dechamps
  • 2,194
  • 8
  • 24
  • 28
0

It might help to use wireshark (http://www.wireshark.org/) and figure out, to what address the packets are being sent.