I am working on Linux.
I added a route to a virtual IP say: 100.10.10.2
by running the command:
route -n add 100.10.10.2 gw 127.0.0.1
It has been redirected to my local loopback. I checked the kernel IP table and it has the path setup correctly. Now, I run a script that binds on the same IP and then try to ping the IP from my machine, it gets the ping reply correctly.
But another computer on the same network cannot ping this virtual IP address. I checked up on the Internet and it does say that I can have multiple IPs on my local loopback and they can be viewed from the peers on the same network.
I tried adding a path on the eth0 interface by replacing the 127.0.0.1
by my eth0
IP address. The information was added to the route table correctly, but then the same thing happened: I was able to ping from my own machine but the peer couldn't.
I Googled up the same thing but none of the solutions helped me out.
The script (it send back ICMP packet replies) is correct (I am sure of that) since I get ping replies from my own machine for the IP which I set up the route for.
Where am I going wrong? Or am I missing out on some configuration?
Any help is much appreciated!
EDIT:
This is the route table
Destination Gateway Genmask Flags Metric Ref Use Iface
100.10.10.2 localhost.local 255.255.255.255 UGH 0 0 0 lo
192.168.1.0 * 255.255.255.0 U 1 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
and interface config:
eth0 Link encap:Ethernet HWaddr 00:22:19:ec:ee:50
inet addr:192.168.1.2 Bcast:10.200.200.255 Mask:255.255.255.0
inet6 addr: fe80::222:19ff:feec:ee50/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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
Best Answer
I am unclear why you're mucking about with route commands on the local system in any case. If you have an address configured on one of your local interfaces, you don't need to specify an explicit route; your system will already know how to contact it.
So for example, if you already have
eth0
configured as above, you should be able to do this:And now your local system will be all set.
For other systems on your network to contact your system at that ip address, one of three things will need to be true. Either:
So if you have another system with the "real" address is 192.168.1.3, then you would either do this:
Or this: