Question

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?

Was it helpful?

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

OTHER TIPS

just edit the /etc/sysconfig/network-scripts/route-ethXX

and write inside: default via ip_address dev device , replace ip_address with your gateway ip and device with the name of the right eth device. but for the Device option its ... optional, set it in the case of multiple eth devices. Works even in case of network restart, the route directive in rc.local works at boot only.

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.

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

Here it is for RHEL, as it is slightly different:

  1. Identify the interface by using ifconfig
  2. sudo vi /etc/sysconfig/network-scripts/route-ethXX
  3. add the routes as per syntax below, where /xx represents subnet mask

    host: 172.30.xxx.xxx via 172.30.xxx.xxx
    network: 172.30.xxx.xxx/xx via 172.30.xxx.xxx
    Default gateway: 0.0.0.0 via xxx.xxx.xxx.xxx</li>
    

  4. Save the file.
  5. sudo /etc/init.d/network restart (Warning: if you forget to set correct routes for the management interface (if applicable) you may lose connectivity to the server)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top