Fresh install of RHL7.0 with two interfaces. The installer did not specify GATEWAYDEV in /etc/sysconfig/network. However, when there is no GATEWAYDEV, and default route has been configured with GATEWAY in /etc/sysconfig/network, all interfaces try to add it and fail with SIOCADDRT. This happens at: --- if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then # set up default gateway if [ "${GATEWAY}" != "" ]; then route add default gw ${GATEWAY} ${DEVICE} DEFGW=${GATEWAY} --- This _might_ have been caused by the fact that in RHL7.0, all interfaces save for eth0 are disabled by default. Fixing this without breaking stuff which use something other than ethX requires some thought (else you could just assume that eth0 == default gateway unless otherwise specified). Perhaps the correct place to fix this would be at install time.
Does this still happen with the beta?
Yes. This can be seen with 'service network restart', which gives like: Jan 30 16:26:07 install5 network: Shutting down interface eth1: succeeded Jan 30 16:26:08 install5 modprobe: modprobe: Can't locate module irlan0 Jan 30 16:26:08 install5 syslogd: sendto: Network is unreachable Jan 30 16:26:08 install5 syslogd: sendto: Network is unreachable Jan 30 16:26:08 install5 sysctl: net.ipv4.ip_forward = 0 Jan 30 16:26:08 install5 sysctl: net.ipv4.conf.all.rp_filter = 1 Jan 30 16:26:08 install5 sysctl: kernel.sysrq = 0 Jan 30 16:26:08 install5 network: Setting network parameters: succeeded Jan 30 16:26:08 install5 ifup: SIOCADDRT: Network is unreachable Jan 30 16:26:08 install5 network: Bringing up interface lo: succeeded Jan 30 16:26:09 install5 network: Bringing up interface eth1: succeeded Note ifup line, as before.
Hmm... we could always ping the gateway, to see if it's reachable at that address. But that's a hack.
We could certainly special-case lo to not try and add it; that would eliminate some of the messages.
OK, here's the fix that's going into initscripts-5.60-1; it seems correct. Change the test from: if [ "${GATEWAY}" != "" ]; then to if [ "${GATEWAY}" != "" -a "`ipcalc --network ${GATEWAY} ${NETMASK}`" = "`ipcalc --network ${IPADDR} ${NETMASK}`" ]; then
(of course, replace the second ipcalc call with just ${NETWORK} *thwap*)
This doesn't exactly work, but the idea is sound. ipcalc --network ${GATEWAY} ${NETMASK} returns something like NETWORK=1.2.3.4 not 1.2.3.4 ;-) There are ways to get around this, but it might be useful to add a feature in ipcalc that'd omit NETWORK=, NETMASK= etc. too. I did this with: if [ "${GATEWAY}" != "" -a "`ipcalc --network ${GATEWAY} ${NETMASK}`" = "NETWORK=${NETWORK}" ]; then and the original bug disappeared. A bit hackish.
Oops, yeah. Disregard the parenthetical comment entirely. :) It's hackish, but it seems the quickest way to determine if you're adding the gateway on a reasonably appropriate interface.