实现文本无线上网

首先ifconfig查找自己的网卡标示。
然后ifconfig wlan0 up 开启网卡.

第一步:
/sbin/iwlist wlan0 scan 查找可用的无线ap
得到的结果如:
Cell 01 - Address: 00:11:22:33:44:55
                    ESSID:"00001"
                    Mode:Master
                    Channel:6
                    Frequency:2.437 GHz (Channel 6)
                    Quality=75/100  Signal level=-59 dBm  Noise level=-80 dBm
                    Encryption key:on
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                       Preauthentication Supported
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              12 Mb/s; 24 Mb/s; 36 Mb/s; 9 Mb/s; 18 Mb/s
                              48 Mb/s; 54 Mb/s
                    Extra:tsf=0000000064554a71

这里我们感兴趣的是ESSID,Channel,Encryption key,Group Cipher,Pairwise Ciphers,Authentication Suites。
第二步:
/sbin/iwconfig wlan0 mode managed channel 6 key off essid 00001
/sbin/iwconfig wlan0 ap 00:11:22:33:44:55

因为ap是WPA2加密,所以接下来我们要先配置/etc/wpa_supplicant.conf 。
network={
scan_ssid=0
ssid="00001"
proto=WPA2
key_mgmt=WPA-PSK
pairwise=TKIP CCMP
group=TKIP
psk="your password"
}
第三步:
/usr/sbin/wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
下面就能配置自己的ip和网关和DNS了。

第四步:配置自己的ip地址
/sbin/ifconfig wlan0 192.168.1.10 netmask 255.255.255.0
/sbin/route add default gw 192.168.1.1
最后在/etc/resolv.conf 里
nameserver 211.161.46.84
nameserver 211.161.46.85

这里就结束了,应该可以上网了。
最后断开网络后,记得
/sbin/route del default gw 192.168.1.1
/sbin/iwconfig wlan0 mode managed key off ap off essid off

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值