From owner-freebsd-questions@FreeBSD.ORG Sat Sep 4 17:19:47 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F225216A4CE for ; Sat, 4 Sep 2004 17:19:46 +0000 (GMT) Received: from shockwave.systems.pipex.net (shockwave.systems.pipex.net [62.241.160.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F88843D1D for ; Sat, 4 Sep 2004 17:19:46 +0000 (GMT) (envelope-from mark.cullen@dsl.pipex.com) Received: from laptop (81-178-75-99.dsl.pipex.com [81.178.75.99]) by shockwave.systems.pipex.net (Postfix) with SMTP id 998561C00086; Sat, 4 Sep 2004 18:19:42 +0100 (BST) Message-ID: <002f01c492a3$05bd8ed0$f800000a@laptop> From: "Markie" To: , "Remko Lodder" Date: Sat, 4 Sep 2004 18:17:10 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Subject: Re: Better way to get interface assigned to default route? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2004 17:19:47 -0000 Stupid me forgot to forward it back to the list, hit the wrong button. Sorry :-D ----- Original Message ----- From: "Markie" To: "Remko Lodder" Sent: Saturday, September 04, 2004 6:15 PM Subject: Re: Better way to get interface assigned to default route? | ----- Original Message ----- | From: "Remko Lodder" | To: "Markie" | Cc: | 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 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 |