Take the 2-minute tour ×

I'm unsure of what's causing my instability but here's what I know:

The server is running Debian with no GUI.

I have a static IP, and /etc/network/interfaces is configured with a 'gateway x.x.x.1' entry.

Periodically, my server loses all internet connectivity, and when I can get to it for access, the default gateway is missing from the routing table.

Because this error halts all traffic to my server, I've set up a cronjob to periodically attempt to 'route add default gw x.x.x.1' so that I don't have to keep physically returning to the machine. I'd like a better solution...


auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
up route add default gw
dns-search domain.com

Why doesn't the entry: up route add default gw x.x.x.1 work in /etc/network/interfaces to keep the gateway in the routing table? Moreover, shouldn't the 'gateway x.x.x.1' entry already make sure that the default gateway stays in the routing table?

Also, what log files should I be looking at in order to track down this reoccurring error?

Side question: could a DoS type attack cause eth0 to go down?

share|improve this question
Can you post the full interfaces file? If you are concerned about sharing public addresses, then just use RFC1918 address space. –  Zoredache Mar 1 '12 at 21:55
That up route add default gw is useless and unnecessary when you have a "gateway" entry. –  daff Aug 14 '12 at 20:26

4 Answers 4

up vote 4 down vote accepted

The ifconfig command is not intended to setup anything other than the interface itself, so no gateway is involved.

When you run ifconfig down, the gateway is removed by the kernel because it sees it is no longer valid.

When you run ifconfig up, the kernel can't guess anything about the gateway.

You should use your distro specific command to up the interface (for example with Debian this is ifup eth0), or explicitly use the route command.

share|improve this answer
Is there any way to make the kernel aware of the necessary gateway setting? I figured that /etc/network/interfaces would do that... Also, I am unsure of what is causing the problem, I just need a way so that when eth0 comes back up, the gateway route comes with it. –  Andrew Parker Mar 2 '12 at 3:28
I just wrote the answer: you should use your distro specific command. Period. This is also "ifip" and "ifdown" for RedHat. –  Gregory MOUSSAT Mar 2 '12 at 7:19
Type: ifup, not ifip –  Gregory MOUSSAT Mar 2 '12 at 18:06
Yes, but those are commands. I'm not issuing any commands, and my routing table is still losing its route to the gateway. –  Andrew Parker Mar 3 '12 at 0:18
So you have to clarify your question. Use the edit link for that. –  Gregory MOUSSAT Mar 3 '12 at 11:54

I am not sure about debian but redhat requires the sysconfig scripts to be configured in order to keep the gateway settings. I am not sure how relevant this is to debian but it drove me nuts on redhat.

share|improve this answer
All you need to do is add a one line GATEWAY=X.X.X.X to /etc/sysconfig/network. There's no way for the OS to automatically know what the gateway is, since it varies depending on the network. –  devicenull Mar 2 '12 at 3:42
That is correct. I am not sure if debian uses the network sysconfig. Seems like it didn't last time I played with it. –  DaffyDuc Mar 2 '12 at 4:34

Okay, first off, why are you using ifconfig? On a normal server, you wouldn't touch that unless you were changing IP addresses.

I suspect you have a copy of the DHCP client running somewhere. I've seen intermittent issues like this when dhclient wakes up near the end of the lease expiration time. Make sure this is fully disabled (you can probably go so far as chmod -x or even removing it, as it has no real purpose on production servers). Check ps aux and make sure you don't see anything relating to DHCP.

Last, a DoS attack will not have any effect on your system's gateway address. It's possible it could cause the gateway to go down (if it overwhelms the router), but it would not cause your system to suddenly remove it from your routing table.

share|improve this answer
I'm just trying to trace what's happening to my server and why it keeps losing its route to the gateway (it just so happens that ifconfig up/down also does exactly this and I'm looking for a way to ensure that the gateway route comes up along with eth0). My server periodically goes offline, and I have to physically visit it to get it reconnected, and when I do, the route to the gateway is missing from the routing table... There's no DHCP, everything is static, no dhcp related items in ps aux. –  Andrew Parker Mar 2 '12 at 4:53
@AndrewParker It is probably not necessary to mention, but be sure to check for "dhclient" in the ps aux output, not simply for a pattern containing "dhcp". –  daff Aug 14 '12 at 20:25

Not a solution but a quick fix to keep you from driving in to correct the config file.

Put a bash together that checks connectivity. If it can't get out have it append the gateway to the config file and bounce networking. At least for now it would save you the down time and driving.

Sorry for creating another answer... can't append comments yet apparently.

share|improve this answer
Like a shell script? I currently have cron putting the route back into the routing table every few hours... –  Andrew Parker Mar 2 '12 at 5:49
Just thought I would mention it incase you didn't. And of course I meant a scheduled script :D –  DaffyDuc Mar 2 '12 at 6:13

Your Answer


