Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Missing route
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Tue Feb 01, 2005 10:19 am    Post subject: Missing route Reply with quote

Whenever I boot up my machine, I find the entry for the default route/gateway is missing from the routing table. However, the correct gateway is specified in /etc/conf.d net. Can anyone suggest any other reason that it might not be being set, as I can't think of anything?
I can work around it by running 'route' and re-mounting NFS shares once the machine is up, but it would be better to have this working.
Back to top
View user's profile Send private message
CriminalMastermind
Tux's lil' helper
Tux's lil' helper


Joined: 19 Nov 2003
Posts: 132
Location: toronto

PostPosted: Tue Feb 01, 2005 10:54 am    Post subject: Reply with quote

milothurston wrote:
However, the correct gateway is specified in /etc/conf.d net.

is it specified in the correct way(ie with an interface)? mine looks like...
Code:
gateway="eth0/192.168.1.1"


the default gateway is setup in /etc/init.d/net.eth?. has anything bad happened to that file?

does it have a part like this in it?
Code:
       if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
        then
                ebegin "  Setting default gateway"
                # First delete any existing routes if it was setup by kernel ..
                /sbin/route del default dev ${gateway%/*} &>/dev/null
                /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
                        netmask 0.0.0.0 metric 1 >/dev/null || {

                        local error=$?
                        ifconfig ${IFACE} down &>/dev/null
                        eend ${error} "Failed to bring ${IFACE} up"
                        stop
                        return ${error}
                }
                eend 0
        fi


what about error messages when you system is booting?
_________________
"I can picture a perfect world that knows of no war... and I can picture me attacking that world, because they'd never expect it."
Back to top
View user's profile Send private message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Tue Feb 01, 2005 11:05 am    Post subject: Reply with quote

CriminalMastermind wrote:
[
does it have a part like this in it?
Code:
       if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
        ...




No it does not - how strange.
I'll try re-emerging baselayout to see if that fixes it.
Thanks.
Back to top
View user's profile Send private message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Tue Feb 01, 2005 11:17 am    Post subject: Reply with quote

No luck - it seems that net.eth0 is a symlink to net.lo, and this is also the case in any rc-script tarballs that I download.
Would you mind posting a copy of your complete net.eth0 script so that I could diff them, please?
Back to top
View user's profile Send private message
CriminalMastermind
Tux's lil' helper
Tux's lil' helper


Joined: 19 Nov 2003
Posts: 132
Location: toronto

PostPosted: Tue Feb 01, 2005 7:35 pm    Post subject: Reply with quote

sure,
Code:

#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.31 2003/09/08 00:11:54 azarah Exp $

#NB: Config is in /etc/conf.d/net


# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
        use hotplug pcmcia
}

checkconfig() {
        if [ -z "${iface_IFACE}" ]
        then
                eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"
                return 1
        fi
        if [ -n "${vlans}" -a \! -x /sbin/vconfig ]
        then
                eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
                return 1
        fi
}

setup_env() {
        # No reason to check these multiple times in the file
        iface="${1/\./_}"
        iface_IFACE="$(eval echo \$\{iface_${iface}\})"
        dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${iface}\})"
        inet6_IFACE="$(eval echo \$\{inet6_${iface}\})"
        alias_IFACE="$(eval echo \$\{alias_${iface}\})"
        status_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/Link/ { if ($1 == IFACE) print "up" }')"
        vlans="$(eval echo \$\{iface_${IFACE}_vlans\})"
}

iface_start() {
        local retval=0

        setup_env ${1}
        checkconfig || return 1

        local IFACE="${1}"
        ebegin "Bringing ${IFACE} up"
        if [ "${iface_IFACE}" != "dhcp" ]
        then
                /sbin/ifconfig ${IFACE} ${iface_IFACE} >/dev/null || {
                        retval=$?
                        eend ${retval} "Failed to bring ${IFACE} up"
                        return ${retval}
                }
                # ifconfig do not always return failure ..
                /sbin/ifconfig ${IFACE} &> /dev/null || {
                        retval=$?
                        eend ${retval} "Failed to bring ${IFACE} up"
                        return ${retval}
                }
        else
                # Check that eth0 was not brough up by the kernel ...
                if [ "${status_IFACE}" != "up" ]
                then
                        /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || {
                                retval=$?
                                eend ${retval} "Failed to bring ${IFACE} up"
                                return ${retval}
                        }
                fi
        fi
        eend 0

        if [ -n "${alias_IFACE}" ]
        then
                local x=""
                local num=0
                local aliasbcast=""
                local aliasnmask=""

                ebegin "  Adding aliases"
                for x in ${alias_IFACE}
                do
                        aliasbcast="$(eval echo \$\{broadcast_${iface}\} \| awk \'\{ print \$$((num + 1)) \}\')"
                        if [ -n "${aliasbcast}" ]
                        then
                                aliasbcast="broadcast ${aliasbcast}"
                        fi

                        aliasnmask="$(eval echo \$\{netmask_${iface}\} \| awk \'\{ print \$$((num + 1)) \}\')"
                        if [ -n "${aliasnmask}" ]
                        then
                                aliasnmask="netmask ${aliasnmask}"
                        fi

                        ebegin "    ${IFACE}:${num}"
                        /sbin/ifconfig ${IFACE}:${num} ${x} \
                                ${aliasbcast} ${aliasnmask} >/dev/null
                        num=$((num + 1))
                        eend 0
                done
                save_options "alias" "${alias_IFACE}"
        fi

        if [ -n "${inet6_IFACE}" ]
        then
                local x=""
                ebegin "  Adding inet6 addresses"
                for x in ${inet6_IFACE}
                do
                        ebegin "    ${IFACE} inet6 add ${x}"
                        /sbin/ifconfig ${IFACE} inet6 add ${x} >/dev/null
                        eend 0
                done
                save_options "inet6" "${inet6_IFACE}"
        fi


        if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
        then
                ebegin "  Setting default gateway"
                # First delete any existing routes if it was setup by kernel ..
                /sbin/route del default dev ${gateway%/*} &>/dev/null
                /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
                        netmask 0.0.0.0 metric 1 >/dev/null || {

                        local error=$?
                        ifconfig ${IFACE} down &>/dev/null
                        eend ${error} "Failed to bring ${IFACE} up"
                        stop
                        return ${error}
                }
                eend 0
        fi

        # Enabling rp_filter causes wacky packets to be auto-dropped by
        # the kernel.  Note that we only do this if it is not set via
        # /etc/sysctl.conf ...
        if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ] && \
           [ -z "$(egrep '^[^#]*rp_filter' /etc/sysctl.conf 2>/dev/null)" ]
        then
                echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
        fi
}

iface_stop() {
        local myalias="$(get_options alias)"
        local myinet6="$(get_options inet6)"

        setup_env ${1}
        local IFACE="${1}"

        ebegin "Bringing ${IFACE} down"

        # Also down the inet6 interfaces
        if [ -n "${myinet6}" ]
        then
                local x=""
                for x in ${myinet6}
                do
                        /sbin/ifconfig ${IFACE} inet6 del ${x} >/dev/null
                done
        fi

        # Do some cleanup in case the amount of aliases change
        if [ -n "${myalias}" ]
        then
                local x=""
                local num=0
                for x in ${myalias}
                do
                        /sbin/ifconfig ${IFACE}:${num} down >/dev/null
                        num=$((num + 1))
                done
        fi

        if [ "${iface_IFACE}" = "dhcp" ]
        then
                local count=0
                while /sbin/dhcpcd -z ${IFACE} &>/dev/null && [ "${count}" -lt 9 ]
                do
                        # Give dhcpcd time to properly shutdown
                        sleep 1
                        count=$((count + 1))
                done
                if [ "${count}" -ge 9 ]
                then
                        eerror "Timed out trying to stop dhcpcd"
                fi
        else
                /sbin/ifconfig ${IFACE} down >/dev/null
        fi
        eend 0
}

start() {
        iface_start ${IFACE} || return 1
        for vlan in ${vlans}
        do
                /sbin/vconfig add ${IFACE} ${vlan} >/dev/null
                iface_start ${IFACE}.${vlan}
        done
}

stop () {
        setup_env ${IFACE}
        checkconfig || return 1
        for vlan in ${vlans}
        do
                iface_stop ${IFACE}.${vlan}
                /sbin/vconfig rem ${IFACE}.${vlan} >/dev/null
        done
        iface_stop ${IFACE}
}

# vim:ts=4


fyi: i just took a look and my baselayout is kind of old. i'm running 1.8.6.10-r1, and 1.9.4-r6 is out. there is a possibility, that they have changed this startup script. just figured i'm mention that.
_________________
"I can picture a perfect world that knows of no war... and I can picture me attacking that world, because they'd never expect it."
Back to top
View user's profile Send private message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Tue Feb 01, 2005 7:43 pm    Post subject: Reply with quote

Thanks - that's very different.
I have the latest baselayout. However, cramming the "gateway" code you originally posted into that seems to have done the trick, though it is far from ideal (I get some errors on boot).
Presumably, as the format has changed the gateway must be set somewhere else now...
Back to top
View user's profile Send private message
cazze
Apprentice
Apprentice


Joined: 26 Mar 2003
Posts: 155
Location: Brussels - Belgium

PostPosted: Tue Feb 01, 2005 7:56 pm    Post subject: Reply with quote

In the doc of the new baselayout, there is an example like this:

ifconfig_eth0=(
"172.16.26.100 netmask 255.255.255.0"
)

route_eth0=(
"default gw 172.16.26.252"
)

kammicazze
_________________
Required: Windows 95 or better, so i installed Linux!!!
Back to top
View user's profile Send private message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Wed Feb 02, 2005 9:23 am    Post subject: Reply with quote

Found it - thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum