views:

1919

answers:

4

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?

+1  A: 

I have not used recent versions of Fedora, but it was often set as a GATEWAY variable in /etc/sysconfig/network.

Of course, if you just wanted it to work, you could just put the commands in /etc/rc.local to be executed when the boot sequence completes.

zigdon
GATEWAY is usually in /etc/sysconfig/network-scripts/ifcfg-eth0, not in /etc/sysconfig/network.
Paul Tomblin
Paul, zigdon was right, there is a GATEWAY entry, but it was there all along and apparently was ineffective.
Richard T
I've usually just bodged this into /etc/rc.local when I've needed to set up multiple static routes; as long as you don't have any services that rely on that route early on (like an nfs mount), it may be the most expedient solution.
Tim Howland
As I wrote in my original question, rc.local is way late.
Richard T
A: 

Before you go to the mailing list (which is probably a good place but might take some time to give an answer), maybe check the IRC channel? I'm not familiar with Fedora, but for other distros I've found IRC to be a nice and quick way for questions like this one.

A: 

Haven't seen Fedora. But shouldn't there be some GUI for this kind of thing? If you have Gnome try running gnome-network-preferences

John Nilsson
+3  A: 

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

Paul Tomblin
Thanks, Paul. The answer is: put your gateway line in the appropriate interface's script in /etc/sysconfig/network-scripts/ - just as you suggest.
Richard T