Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My debian system has the ip address and I would like to configure a default gateway which is not on the network. As a first step I want to add a route so that I can reach the gateway from the system. So I run this command (which I thought will enable a static route to a single host), but I still can't ping the gateway:

# ip route add dev eth0
# ping
PING ( 56(84) bytes of data.
--- ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms

Here's my configuration:

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface UH        0 0          0 eth0   U         0 0          0 eth0

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr ca:eb:7c:e6:7e:98  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::c8eb:7cff:fee6:7e98/64 Scope:Link
          RX packets:45 errors:0 dropped:0 overruns:0 frame:0
          TX packets:291 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:52454 (51.2 KiB)  TX bytes:39433 (38.5 KiB)

# cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The internal network interface
allow-hotplug eth0
iface eth0 inet static

# cat /proc/sys/net/ipv4/ip_forward 

I have verified that the gateway will respond to ping if I use an IP address in its network, unfortunately that is not an option because the system can't have a real (not in 192.168.x.x) ip address in that range.

share|improve this question
Solved: the gateway also needs to reach the debian system, so it must have a route too: ip route add dev eth0 . See comment below. – nn4l Aug 21 '12 at 9:57

3 Answers 3

up vote 2 down vote accepted

Does your default-gateway-to-be know the way back to your machine?

Though you two ( and share a common layer2 ("ethernet") both must know how to reach each other. Normally, they share a common layer3 ("ip subnet"), but in this case the gw has to have a route to (/24? at least /32) to it's device connected to the common l2.

Do you have administrative access to your gw?

share|improve this answer
This is correct. The router needs a route back to – bahamat Aug 14 '12 at 9:43
thanks, I was able to resolve the problem by adding the missing route on the gateway by running ip route add dev eth0 – nn4l Aug 21 '12 at 9:55

I'm assuming that is on a different Ethernet domain. In order to communicate with hosts on a different Ethernet domain the host must use a gateway to get there. The route you've added specifies that is directly reachable, which is why it is failing. You need to provide an appropriate gateway to use. Assuming that is the gateway on the local network:

ip route add via

If the gateway is on the same Ethernet domain, it either doesn't know how to route packets back to your machine, or the packets are getting filtered somewhere. The gateway either needs a route for on the local network, or you need to add an IP address to your machine which is in the gateway's local subnet.

Once that is setup check that ARP is working on both machines:

arp -n | grep

You should see a HWaddress listed. Do the same on the gateway for your machine's IP. If it still doesn't work check firewalls and possibly reverse path filtering.

share|improve this answer
The server should be directly reachable as this system is connected to the same switch as Also I don't have any router on the network. – nn4l Aug 14 '12 at 7:47
@mgorven: That's not necessarily a safe assumption. IP packets from different subnets can co-exist on the same ethernet domain and will pass "like ships in the night" unbeknownst to each other. After all, L2 has nothing to do with L3. – bahamat Aug 14 '12 at 9:46
@bahamat Sure, but it's a less common configuration, hence my assumption in the face of insufficient information. – mgorven Aug 14 '12 at 16:57

Can you add another IP address to eth0 iterface?

ifconfig eth0:1 netmask x.x.x.x up


route add default gw

Is it ok for you?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.