Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Dec 2005 09:57:03 +0800
From:      Yuan Jue <yuanjue02@gmail.com>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Wireless NIC in FreeBSD 6.0 ?
Message-ID:  <200512280957.03981.yuanjue02@gmail.com>
In-Reply-To: <20051226161222.GA1038@flame.pc>
References:  <200512251530.21898.yuanjue02@gmail.com> <200512261107.45871.yuanjue02@gmail.com> <20051226161222.GA1038@flame.pc>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 27 December 2005 00:12, Giorgos Keramidas wrote:
> On 2005-12-26 11:07, Yuan Jue <yuanjue02@gmail.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512280957.03981.yuanjue02>