New to linux networking, had a question about routing to virtual ip addresses from a different subnet.

I have three servers (they can all ping each other):

A (connected to router Y)
B (connected to router Y)
C (connected to router Z)

On server A, I created 1000 virtual interfaces:

# ifconfig eth0:0 netmask  
# ifconfig eth0:1 netmask  
# ifconfig eth0:999 netmask  

Each virtual interface is simulating a camera device, with camera simulation software.

On server B, I added the following route:

# route add -net netmask eth0

And voila, B can access/ping the virtual interfaces of machine A.

Server C that is on a different subnet (, added this route, but even I had super low hope for it to work:

# route add -net netmask eth0

As expected, I wasn't able to reach the virtual interfaces of server A, so I removed the route and added the following route using gateway ip of router Y:

# route add -net netmask gw eth0
SIOCADDRT: Network is unreachable

The gateway is pingable by server C, however I think the error message implies that the gw is not directly on the same subnet (10.10.60).

What configuration/route can be configured on server A and/or C for C to ping/access the virtual interfaces of server A. I don't have access to change the configuration of the routers.

Though, if it's absolutely not possible using changing just the configuration of the servers, could someone please explain in networking terms why B can access virtual interfaces of A, but C cannot access them. Does the router Y see packets bound to '' from C and automatically drop them, whereas when packets originating from the same subnet (B) get allowed?

2 Answers 2


Simple solution create a tunnel between the two servers, e.g:

On server A:

ip tunnel add tunnel mode ipip remote
ip addr add dev tunnel
sysctl -w net.ipv4.ip_forward=1

The last command is to forward packets from your newly created tunnel device to your virtual ethernet devices.

On Server C

ip tunnel add tunnel mode ipip remote
ip addr add dev tunnel
ip route add via

Depending on your firewalls between the servers you may have to adjust some rules.

Explenation: Server A and Server B are on a shared network segment, e.g. they can send packets to each other without the need to send the packets to their gateway. This means Server B just tries directly to resolve the address via ARP and Server A replies to them.

Server A and Server C are on different network segments, e.g. if Server C just asks for (this would be your route command for Server C) it will receive no answer. To solve this problem you generally can specify how you can reach a specific system via routing tables but you can only specify the next hop. As router Z seems to not know about you have to create a tunnel between the two systems.

One small additional hint, you don't need to create virtual ethernet devices, you can add an arbitrary number of ip addresses to one network device, e.g:

for first in {1..4} ; do
   for second in {1..255} ; do
     ip addr add 192.168.$first.$second/16 dev eth0
  • Thanks, this was exactly what I needed. Following your instructions, almost verbatim, and I'm able to connect to all my virtual cameras.
    – Saad Malik
    Jul 27, 2012 at 2:34
  • The only addition to make it all work: ip link set dev tunnel up
    – Saad Malik
    Jul 27, 2012 at 2:35
  • I've been reading a ton about ipip, gre, and sit; some very interesting protocols. Out of curiosity, if I had 20 servers that need to connect to server A using tunneling, would I be required to create 20 separate tunnels on A or can I specify 'remote any' for the tunnel configuration on server A. Before I get down vote, I already tried and failed, but maybe there is a way or is this not possible?
    – Saad Malik
    Jul 27, 2012 at 19:41
  • @SimFox3 You should starting talking to your network people so they can propagate the necessary routes to your routers. But yes you need 20 different tunnels (each one with a different IP on A) or as an alternative if the 20 servers are on the same network segment create one tunnel and use this server as an router for the network. Jul 27, 2012 at 19:50
  • @UlrichDangel If I have 20 servers on the same network segment. I create one tunnel on server C, and I can connect 192.168.x.x on server C. But how can I connect 192.168.x.x on another servers. I already add route on other servers, using ip route add via
    – cocobear
    Dec 18, 2021 at 2:31

You have a few options:

  • Computer C needs a link to the same physical net as A and B are on.
  • Router Y needs to have an address in and router Z needs a route for via router Y.
  • Create an ip-ip (or VPN) tunnel between computer C and computer A; route traffic for via the tunnel interface.

Creating the tunnel is probably your best bet for modifying only computers A and C. See the IP-IP Howto for steps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .