Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Sep 2004 18:17:10 +0100
From:      "Markie" <mark.cullen@dsl.pipex.com>
To:        <freebsd-questions@freebsd.org>, "Remko Lodder" <remko@elvandar.org>
Subject:   Re: Better way to get interface assigned to default route?
Message-ID:  <002f01c492a3$05bd8ed0$f800000a@laptop>

next in thread | raw e-mail | index | archive | help
Stupid me forgot to forward it back to the list, hit the wrong button.
Sorry :-D

----- Original Message -----
From: "Markie" <mark.cullen@dsl.pipex.com>
To: "Remko Lodder" <remko@elvandar.org>
Sent: Saturday, September 04, 2004 6:15 PM
Subject: Re: Better way to get interface assigned to default route?


| ----- Original Message -----
| From: "Remko Lodder" <remko@elvandar.org>
| To: "Markie" <mark.cullen@dsl.pipex.com>
| Cc: <freebsd-questions@freebsd.org>
| Sent: Saturday, September 04, 2004 5:23 PM
| Subject: Re: Better way to get interface assigned to default route?
|
|
| | Hi Markie,
| |
| | Markie wrote:
| |
| | > Hi all,
| | >
| | > I just now replaced my 350MHz PII home server back to the old 133MHz
PI
| to
| | > see if my crashing problems went away. I have noticed that
| dhclient-script
| | > does a `netstat -rn | grep "^default" | awk {'print $6'}` to get the
| | > interface that the default route is on, in my case my dsl modem is on
| fxp1.
| | > Since this is a slow machine however, this takes a very long time for
| it to
| | > do that command as I seem to have quite alot of...routing entries I
| guess
| | > they are?
| |
| | Okay it seems to me that you want to use DHCP in order to get your ass
| | (machine) in the internet. That seems rather logically, only i use the
| | dhclient <interface> command (dhclient rl0 for example). To me it
sounds
|
| Suggesting I do `dhclient fxp1`? That's exactly my problem though :-)
That
| uses /sbin/dhclient-script to do all of it's work, right? dhclient-script
| tries to figure out the interface... or something to do with a default
| route by doing that netstat -rn command.
|
| dhclient-script snippet...
| ----
| if [ x$alias_subnet_mask != x ]; then
|   alias_subnet_arg="netmask $alias_subnet_mask"
| fi
|
| # Get the interface to which our default route is bound to.
| if [ -x /usr/bin/netstat ]; then
|        if_defaultroute=`/usr/bin/netstat -rn \
|                | /usr/bin/grep "^default" \
|                | /usr/bin/awk '{print $6}'`
| else
|         if_defaultroute="x"
| fi
|
| if [ x$reason = xMEDIUM ]; then
|   eval "ifconfig $interface $medium"
|   eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
|   sleep 1
|   exit_with_hooks 0
| fi
| ---
|
| See it? Basically I am after some sort of command that might be able to
get
| the interface with the default route assigned but quicker than
netstat -rn
| since I have alot of routing table entries. Like I said, if there's no
| other way I will just have to fix it so it's if_defaultroute = "fxp1".
|
| I've already had to make some changes to the script to get it to work
with
| my modem anyway so it won't hurt me :-) I was just wondering if there was
| any other nice way of doing it so that say if I changed the internet
| interface to a vx card I wouldn't have to try and remember to change that
| to vx0 (I _will_ forget I made the change :-)
|
| | rather silly to do a netstat -rn command, checkup the default route
| | interface and then add dhcp stuff into it.. since dhcp sets these
| | default route for me..
| |
| | Perhaps you can try and see if that works quicker :)
| |
| | Cheers
| |
| |
|
| Thanks
|
| | --
| | Kind regards,
| |
| | Remko Lodder                   |remko@elvandar.org
| | Reporter DSINet                |remko@dsinet.org
| | Projectleader Mostly-Harmless  |remko@mostly-harmless.nl
|



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002f01c492a3$05bd8ed0$f800000a>