From owner-freebsd-mobile@FreeBSD.ORG Sat Mar 28 16:53:06 2009 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 109571065670 for ; Sat, 28 Mar 2009 16:53:06 +0000 (UTC) (envelope-from oberman@es.net) Received: from mailgw.es.net (mail1.es.net [IPv6:2001:400:201:1::2]) by mx1.freebsd.org (Postfix) with ESMTP id EED428FC0C for ; Sat, 28 Mar 2009 16:53:05 +0000 (UTC) (envelope-from oberman@es.net) Received: from ptavv.es.net (ptavv.es.net [IPv6:2001:400:910::29]) by mailgw.es.net (8.14.3/8.14.3) with ESMTP id n2SGr4WC019692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 28 Mar 2009 09:53:05 -0700 Received: from ptavv.es.net (ptavv.es.net [127.0.0.1]) by ptavv.es.net (Tachyon Server) with ESMTP id B566F1CC09; Sat, 28 Mar 2009 09:53:04 -0700 (PDT) To: "J. Porter Clark" In-reply-to: Your message of "Sat, 28 Mar 2009 11:08:58 CDT." <20090328160858.GA57695@auricle.charter.net> Date: Sat, 28 Mar 2009 09:53:04 -0700 From: "Kevin Oberman" Message-Id: <20090328165304.B566F1CC09@ptavv.es.net> Cc: freebsd-mobile@freebsd.org Subject: Re: Switching from wired to wireless getting "network down" X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2009 16:53:06 -0000 > Date: Sat, 28 Mar 2009 11:08:58 -0500 > From: "J. Porter Clark" > Sender: owner-freebsd-mobile@freebsd.org > > >> Date: Fri, 27 Mar 2009 10:04:29 -0700 > >> From: Jason Nordwick > >> Sender: owner-freebsd-mobile@freebsd.org > >> > >> This appears to be the case. "route get 192.168.1.1" (my netgear wireless) > >> shows that it still wants to use bfe0 instead of the wpi0 interface. How do > >> I get it so that when I unplug my cable and my wireless is up, it changes > >> the routing table? > >> > >> -j > >> > >> > >> On Fri, Mar 27, 2009 at 9:31 AM, Jason Nordwick wrote: > >> > >> > I just updated to the current -STABLE (7.2-PRERELEASE is the same thing? > >> > hopefully). > >> > > >> > When I boot with the network cable plugged in, but then try to unplug it > >> > and up my wireless, it doesn't seem to work although the ifconfig shows I am > >> > joined to my wireless network. Is there some magic I need to do to reset the > >> > routing tables or something? > > >Depends on your configuration. Do you use DHCP or static network > >configurations? If it is DHCP, I suspect /etc/rc.d/dhclient restart > >would do the trick. If it is status: > >route add default abc.def.gh.ij > >should do the trick. > > >Going the other way can be a tiny bit more involved. 'ifconfig wlan0 > >down' first or 'route delete default' to get rid of the current > >static. (Note: wlan0 on stable needs to be replaced with the name of > >your wireless interface.) > > I've been playing around with this sort of setup, too, where I > want a command line to change from wired to wireless (at the > same IP address, even) and back again. I haven't found the > magic solution, particularly one that doesn't have a lot of > hardcoded network config in it. I'm also somewhat ticked that > "route flush" doesn't really flush all routes like the man page > says. 8-) Eventually, I usually arrive at a point where I can't > find my way back and have to reboot to get some work done. > > Some things I've been using are "route delete " > and "route add -ifp default". Might be a good idea > to "arp -a -d", too. OK. Here is the script I use to switch between the wired and wireless at work. I use it often, so I know it works with 7.1-Stable of early February. It switches between wired (bge0) and wireless (ath0). All addressing is static on bge0 and DHCP on ath0, though this really does not matter if your rc.conf is correct for both interfaces. By using the rc.d scripts, I take care of a lot of annoying details because they already DTRT. #!/usr/bin/perl use strict; my ($data); # Get the current default route interface ($data) = `netstat -rnf inet | grep default`; if (grep /bge0/, $data) { # Move to wireless (ath0) # make sure that the wireless driver is loaded! $data = `kldstat | grep if_ath.ko`; if ($?) {`kldload if_ath`;} # Move to wireless (ath0) ($data) = `/etc/rc.d/routing stop`; print $data; ($data) = `/etc/rc.d/netif stop bge0`; print $data; ($data) = `/etc/rc.d/netif start ath0`; print $data; print "Connected via wireless\n"; } else { # Move to .1 wire (bge0) ($data) = `/etc/rc.d/netif stop ath0`; print $data; ($data) = `route delete default`; print $data; ($data) = `/etc/rc.d/netif start bge0`; print $data; ($data) = `/etc/rc.d/routing start`; print $data; print STDERR "Connected via ESnet on bge0\n"; } -- R. Kevin Oberman, Network Engineer Energy Sciences Network (ESnet) Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab) E-mail: oberman@es.net Phone: +1 510 486-8634 Key fingerprint:059B 2DDF 031C 9BA3 14A4 EADA 927D EBB3 987B 3751