Search code examples
linuxinstallationdefaultfedoraroutes

How do I make my default (or any static) route permanent on Linux (Fedora 9 specifically)?


I've just performed a new installation of the very latest (Fall, 2008) version of Fedora 9 Linux and am perplexed that it never set the default route properly and that even traveling the labyrinthine ways of this OS, there's no obvious way.

Of course, it's clear that one can do it on a one-off basis like this:

   route add default gw gw1 metric 0 eth0

or like this:

   ip route add to default via 192.168.2.1 protocol static

However, neither of these survives reboot. In reading through /etc/rc.d/init.d/network, it attempts to find data from a file in /etc/sysconfig/static-routes, but that file never existed. So, I tried to create it and populate it with data. The trouble with that is that the script places a dash (minus sign) in an odd spot that I'm not sure how to deal with.

Of course, one can just edit /etc/rc.d/init.d/network, but that would be non-standard. As it is, my only other recourse seems to be editing rc.local, but that doesn't come early enough in the boot sequence to be there for things like, for example, the network time daemon.

I've done my homework - I've read all the man pages, info entries, tried apropos, and I've even done a fair bit of web searching, all to no avail - my next step, sans answer here, will be to sign up to the Fedora mailing lists and ask there! Or, give up and edit the scripts.

So, how is one supposed to do this?


Solution

  • The gateway is normally set in /etc/sysconfig/network-scripts/ifcfg-eth0, not in /etc/sysconfig/network. For example, on my current machine:

    /etc/sysconfig/network

    NETWORKING=yes
    NETWORKING_IPV6=no
    HOSTNAME=flyboys
    NISDOMAIN=ekcineon
    

    /etc/sysconfig/network-scripts/ifcfg-eth0

    DEVICE=eth0
    ONBOOT=yes
    HWADDR=00:1d:09:31:3a:cc
    NETMASK=255.255.255.0
    IPADDR=150.102.65.30
    GATEWAY=150.102.65.252
    TYPE=Ethernet
    

    Note that I set HWADDR because I have two ethernet cards and I want to make sure the right one is assigned to eth0. The configuration for the second card is in /etc/sysconfig/network-scripts/ifcfg-eth1