From owner-freebsd-questions@FreeBSD.ORG Mon Dec 26 16:13:39 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 8C30016A41F for ; Mon, 26 Dec 2005 16:13:39 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id A682343D45 for ; Mon, 26 Dec 2005 16:13:37 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (patr530b-0050.otenet.gr [62.103.226.50]) by rosebud.otenet.gr (8.13.4/8.13.4/Debian-8) with ESMTP id jBQGDYub004769; Mon, 26 Dec 2005 18:13:34 +0200 Received: by flame.pc (Postfix, from userid 1001) id 5908D1171C; Mon, 26 Dec 2005 18:12:22 +0200 (EET) Date: Mon, 26 Dec 2005 18:12:22 +0200 From: Giorgos Keramidas To: Yuan Jue Message-ID: <20051226161222.GA1038@flame.pc> References: <200512251530.21898.yuanjue02@gmail.com> <200512252205.33644.yuanjue02@gmail.com> <43AEB79D.9030200@locolomo.org> <200512261107.45871.yuanjue02@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200512261107.45871.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: Mon, 26 Dec 2005 16:13:39 -0000 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 :)