From owner-freebsd-questions@FreeBSD.ORG Sat Sep 4 23:13:12 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 5DDD616A4CE for ; Sat, 4 Sep 2004 23:13:12 +0000 (GMT) Received: from redqueen.elvandar.org (cust.94.120.adsl.cistron.nl [195.64.94.120]) by mx1.FreeBSD.org (Postfix) with ESMTP id B572E43D3F for ; Sat, 4 Sep 2004 23:13:11 +0000 (GMT) (envelope-from remko@elvandar.org) Received: from [10.0.2.122] (nimrod.elvandar.intranet [10.0.2.122]) by redqueen.elvandar.org (Postfix) with ESMTP id F1C2110685E for ; Sun, 5 Sep 2004 01:13:08 +0200 (CEST) Message-ID: <413A4C06.7070404@elvandar.org> Date: Sun, 05 Sep 2004 01:13:10 +0200 From: Remko Lodder X-Accept-Language: en-us, en MIME-Version: 1.0 To: FreeBSD Questions References: <001701c492a2$c806c2a0$f800000a@laptop> <413A3F0E.3060508@elvandar.org> In-Reply-To: <413A3F0E.3060508@elvandar.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at elvandar.org 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 23:13:12 -0000 Hi, Markie forgot, and forwared this to the list, i forgot and didn't notice it until now that it also had been sent to the list by Markie. So, i will 'reply' this message to the Questions list as well just to keep you guys and the archive updated. Cheers! Remko Lodder wrote: > Markie wrote: > >> 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 :-) >> > > Well, how come there is a default route if you use dhcp afterwards? my > default route is delivered through dhcp.. so i cannot reside on a > default entry because i dont have any... That's why i think that the > default grep is a little bit weird actually, since most hosts dont have > any routes at all at that point in time and then start dhclient > > And to be more exact: > > in /etc/rc.conf i have > ifconfig_em0="DHCP" which starts ``dhclient em0'' for me... i never used > dhclient-script, and didn't read it carefully yet to understand it. > > Perhaps this explains a bit... > > or i just dont get the question yet { have a long weekend, tired etc ;) } > > Cheers dude! > -- Kind regards, Remko Lodder |remko@elvandar.org Reporter DSINet |remko@dsinet.org Projectleader Mostly-Harmless |remko@mostly-harmless.nl