From owner-freebsd-questions@FreeBSD.ORG Wed Dec 28 01:54:22 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 062EE16A41F for ; Wed, 28 Dec 2005 01:54:22 +0000 (GMT) (envelope-from yuanjue02@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id 725F243D49 for ; Wed, 28 Dec 2005 01:54:21 +0000 (GMT) (envelope-from yuanjue02@gmail.com) Received: by zproxy.gmail.com with SMTP id 9so1391458nzo for ; Tue, 27 Dec 2005 17:54:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:organization:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=gQL3YcCtRZuEQPISyGRIe/XC0rewbxQkOK89K3BhPtvbPUSrzGRFYv9K2dbKaVOKwrrQJVwnG/ZD3EK77eC8lpwxqX1mHHcjWrrS4VMQSBUTB8DThcUJFwgfdRUHK1KR2Z0PFSdWx56m3vimf15vmiTnTEc07gOTOL0wNQvEhFU= Received: by 10.36.41.1 with SMTP id o1mr4827321nzo; Tue, 27 Dec 2005 17:54:20 -0800 (PST) Received: from yuanjue.nc6000.org ( [59.66.138.109]) by mx.gmail.com with ESMTP id j4sm4837395nzd.2005.12.27.17.54.17; Tue, 27 Dec 2005 17:54:19 -0800 (PST) From: Yuan Jue Organization: Tsinghua UNIV. To: Giorgos Keramidas Date: Wed, 28 Dec 2005 09:57:03 +0800 User-Agent: KMail/1.8.3 References: <200512251530.21898.yuanjue02@gmail.com> <200512261107.45871.yuanjue02@gmail.com> <20051226161222.GA1038@flame.pc> In-Reply-To: <20051226161222.GA1038@flame.pc> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512280957.03981.yuanjue02@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Wireless NIC in FreeBSD 6.0 ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2005 01:54:22 -0000 On Tuesday 27 December 2005 00:12, Giorgos Keramidas wrote: > On 2005-12-26 11:07, Yuan Jue wrote: > > instead, I figure out another way to work around. > > > > 1.ifconfig bge0 delete > > % this would shut my local NIC down totally > > > > 2.kldload if_ath > > dhclient ath0 > > > > then I can enjoy the wireless internet surfing :) > > > > antway, thank you again! > > FWIW, > > On my laptop, which has to switch between a couple of wireless networks and > my local LAN at home, I use custom shell scripts called ``/root/net/*.sh'' > to encapsulate the changes I'd have to manually make. > > I have prepared working sets of files, like: > > /etc/resolv.conf_home > /etc/resolv.conf_work > > and then run /root/net/home.sh which contains: > > #!/bin/sh > > if test -n "$1" && test -f "/root/netstart-home-$1.sh" ; then > mode="$1" > else > mode=wlan > fi > > echo "## Stopping local services" > /etc/rc.d/named stop > /etc/rc.d/sendmail stop > > echo "## Setting up /etc and /usr/local/etc files" > ( > cd /etc; > cp resolv.conf_home resolv.conf; > cp dhclient.conf_home dhclient.conf; > cp namedb/named.conf_home namedb/named.conf; > > cd /usr/local/etc/postfix; > cp main.cf_home main.cf; > ) > > echo "## Bringing up the network connection" > "/root/net/netstart-home-${mode}.sh" > > echo "## Refreshing the firewall rules" > /etc/rc.d/pf reload > > echo "## Starting local services again" > /etc/rc.d/named start > /etc/rc.d/sendmail start > > The real work is done by netstart-home-wlan.sh or netstart-home-wlan.sh. > The wlan script is the one that sets up a wireless connection, and > contains: > > #!/bin/sh > > # Default setup for my bge0 interface. > export ifconfig_ath0="DHCP ssid 'gker' \ > wepmode on weptxkey 1 wepkey > '1:0xXXXXXXXXXXXXXXXXXXXXXXXXXX'" export defaultrouter="192.168.1.2" > > /etc/rc.d/netif stop bge0 > /etc/rc.d/netif stop ath0 > > echo -n "Waiting for ath0 to associate " > _timeout=0 > _associated=NO > while [ "$_timeout" -lt 30 ]; do > status=$( ifconfig ath0 2>&1 | grep status: |\ > awk '{print $2}' ) > if [ X"${status}" = X"associated" ]; then > _associated=YES > break > fi > echo -n '.' > sleep 1 > _timeout=$(( $_timeout + 1 )) > done > if [ X"${_associated}" = X"YES" ]; then > echo " ok" > else > echo '' > echo "Failed to bring up ath0. Aborting." > /etc/rc.d/netif stop ath0 > exit 1 > fi > > # > # The default route may be pointing to another interface. Find out > # the IP address of the default gateway, delete it and point to the > # default gateway of my home network. > # > if [ -n "${defaultrouter}" ]; then > _oldrouter=`netstat -rn | grep default | awk '{print $2}'` > if [ -n "${_oldrouter}" ]; then > route delete default "${_oldrouter}" > unset _oldrouter > fi > route add default "$defaultrouter" > fi > > This seems to work remarkably well so far. All I need to do once the > laptop boots is to log in as root and run the proper /root/net/*.sh script > :) thanks for your shell scripts. it is very appreciated. thanks again :) -- Best Regards. Yuan Jue