linux如何上网

redhat5 无线上网
一、确认无线网卡可以识别,否则需要安装网卡驱动

# lspci |grep -i wireless
05:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)

# ifconfig -a | grep wlan
wlan0     Link encap:Ethernet  HWaddr 00:19:D2:7F:8E:56

二、配置无线网卡
up网卡
# ifconfig wlan0 up

扫描网络
# iwlist wlan0 sacan
iwlist: unknown command `sacan'
[root@chai redhat]# iwlist wlan0 scan
Warning: Driver for device wlan0 recommend version 21 of Wireless Extension,
but has been compiled with version 20, therefore some driver features
may not be available...

wlan0     Scan completed :
          Cell 01 - Address: 94:0C:6D:18:D6:50
                    ESSID:"he"
                    Mode:Master
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=38/100  Signal level=-86 dBm  Noise level=-127 dBm
                    Encryption key:on
                    IE: WPA Version 1
                        Group Cipher : CCMP 
                        Pairwise Ciphers (1) : CCMP 
                        Authentication Suites (1) : PSK  
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    Extra:tsf=00000000b9b4ad80

连接到无限网络
# iwconfig wlan0 essid "he"
# iwconfig wlan0 channel 1

#使用wpa_supplicant访问wap-psk网络
# wpa_supplicant -Bw -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -D wext -d >/dev/null 2>&1

=================================================================================================================
NOTE:
启动网卡出现错误
# ifconfig wlan0 up
SIOCSIFFLAGS: No such file or directory

系统日志
Jul 16 13:55:02 chai kernel: PCI: Enabling device 0000:05:00.0 (0000 -> 0002)
Jul 16 13:55:02 chai kernel: ACPI: PCI Interrupt 0000:05:00.0[A] -> GSI 19 (level, low) -> IRQ 185
Jul 16 13:55:02 chai firmware_helper[23886]: Loading of /lib/firmware/iwlwifi-3945-1.ucode for iwl3945 driver failed: No such file or directory
Jul 16 13:55:02 chai kernel: iwl3945: iwlwifi-3945-1.ucode firmware file req failed: Reason -2
Jul 16 13:55:02 chai kernel: iwl3945: Could not read microcode: -2
Jul 16 13:55:02 chai kernel: ACPI: PCI interrupt for device 0000:05:00.0 disabled

需要安装软件包
# rpm -ivh iwlwifi-3945-ucode-15.32.2.9-1.el5.noarch.rpm 

开机脚本:
# cat /etc/init.d/wirelessd 
#!/bin/bash
#
# chkconfig:315 65 43
# description: start and stop wireless network

. /etc/init.d/functions

PROG=wirelessd
WLAN_ETH=wlan0
WAP_CONFIG="/etc/wpa_supplicant/wpa_supplicant.conf"
essid=he
WLAN_LOG=/var/log/wireless.log

function start()
{
    ifconfig $WLAN_ETH up >> $WLAN_LOG 2>&1
    iwconfig $WLAN_ETH essid $essid
    /usr/sbin/wpa_supplicant -Bw -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -D wext -d >>$WLAN_LOG 2>&1
    dhclient $WLAN_ETH  >> $WLAN_LOG 2>&1
}

function stop()
{
    wpa_pid=`ps -ef |grep "wpa_supplicant" |grep -v "grep" |awk '{print $2}'`
    wlan_pid=`ps -ef | grep "dhclient wlan0"  |grep -v "grep" | awk '{print $2}'`
    kill -9 $wlan_pid $wpa_pid  >> $WLAN_LOG 2>&1
    ifconfig $WLAN_ETH down  >> $WLAN_LOG 2>&1
}


case "$1" in
  start)
       start
       ;;
  stop)
      stop
      ;;
   restart)
       stop
       start
       ;;
    *)
       echo "Usage:$PROG {start|stop|restart}"
esac

# chkconfig --add wirelessd
# chkconfig --list wirelessd
wirelessd       0:off   1:on    2:off   3:on    4:off   5:on    6:off
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值