无线组网 频道

Uinx系统中无线网络如何轻松快速切换

    完整shell脚本如下:

    #!/bin/sh

    # /usr/local/etc/rc.d/wi0

    # 配置无线网络接口

    # See the ifconfig(8), dhclient(8) and route(8) man pages for further

    # assistance.

    NIC=wi0

    case $1 in

    office)

       ifconfig ${NIC} ssid " office " authmode "shared" nwkey 0x123456789a

       dhclient ${NIC}

       echo ${NIC}
       ;;
    shome)

       ifconfig ${NIC} inet 192.168.1.21 ssid " cjhhome " authmode "shared"

       nwkey 0x127776789a netmask 255.255.255.0

       route add default 192.168.1.1

       echo nameserver 202.204.1.4> /etc/resolv.conf

       echo nameserver 202.204.1.5> > /etc/resolv.conf

       echo ${NIC}

       ;;

    stop)

       [ -s /var/run/dhclient.pid ] && kill `cat /var/run/dhclient.pid` \

           && rm /var/run/dhclient.pid

       ifconfig ${NIC} remove

       echo " ${NIC} removed"

       ;;

    status)

       ifconfig ${NIC}

       ;;

    *)

       echo "usage: /usr/local/etc/${NIC} [office|cjhome|stop|status]"

       ;;

    esac

    赋予shell脚本(/usr/local/etc/rc.d/wi0)执行权限

    # chown root:wheel /usr/local/etc/rc.d/wi0

    # chmod 700 /usr/local/etc/wi0

0
相关文章