Skip to content

Instantly share code, notes, and snippets.

@commshare
Last active April 10, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commshare/2ce2ae79369bf9aa2ec3e1f6d920ca91 to your computer and use it in GitHub Desktop.
Save commshare/2ce2ae79369bf9aa2ec3e1f6d920ca91 to your computer and use it in GitHub Desktop.
enable_wlan0

生成一个密码

root@orangepiplus:~# wpa_passphrase TPLINK-2018 
# reading passphrase from stdin
mypasswd
network={
        ssid="TPLINK-2018"
        #psk="mypasswd"
        psk=8a278324210558dad1a1bb182113f0df8fcee75946d31b25c7b839d98bbd49f7
}
root@orangepiplus:~# 

新建立wpa_supplication.conf并保存

ifconfig看不到,ifconfig -a 可以看到

##ifconfig看到wlan0 更换了网卡芯片以后,重新装驱动,发现用iwconfig查看结果是wlan1,而非wlan0。

原因:在/etc/udev/rules.d/70-persistent-net.rules中记录了插入网卡的先后顺序,第一块插入的为wlan0,因此更换后iwconfig查看结果是wlan1而非wlan0。

解决方法:将/etc/udev/rules.d/70-persistent-net.rules文件中的wlan1和wlan0注释掉,重新启动,用iwconfig查看为wlan0

http://reactivated.net/writing_udev_rules.html

修改interface  (debian的路径是/etc/network/interfaces)

root@orangepiplus:~# ls /etc/network
if-down.d       if-pre-up.d  interfaces       run
if-post-down.d  if-up.d      interfaces.orig  wpa_supplication.conf
root@orangepiplus:~# vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo eth0
allow-hotplug eth0
iface lo inet loopback
iface eth0 inet dhcp

#"your-ssid-here" and "your-passwd-here" should been replase with yours and remove the annotation

auto wlan0
iface wlan0 inet dhcp
#pre-up ip link set wlan0 up
#pre-up iwconfig wlan0 essid NRZ2.4
#wpa-ssid NRZ2.4
#wpa-pk
wpa-conf /etc/network/wpa_supplication.conf
~

~
~
"/etc/network/interfaces" 18L, 400C written                   

重启网络(没插网线千兆)

root@orangepiplus:~# /etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
Reconfiguring network interfaces...Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/00:e0:4c:f0:19:af
Sending on   LPF/wlan0/00:e0:4c:f0:19:af
Sending on   Socket/fallback
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/de:52:95:4c:f5:90
Sending on   LPF/eth0/de:52:95:4c:f5:90
Sending on   Socket/fallback
DHCPRELEASE on eth0 to 192.168.1.1 port 67
send_packet: Network is unreachable
send_packet: please consult README file regarding broadcast address.
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

[  559.158939] gmac0: probed
[  559.162029] gmac0 gmac0: eth0: eth0: PHY ID 0000ffff at 0 IRQ poll (gmac0-0:00)
[  559.180351] gmac0 gmac0: eth0: Initialize hardware error
Listening on LPF/eth0/de:52:95:4c:f5:90
Sending on   LPF/eth0/de:52:95:4c:f5:90
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
send_packet: Network is down
receive_packet failed on eth0: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5
send_packet: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
send_packet: Network is down
No DHCPOFFERS received.
Trying recorded lease 192.168.1.194
connect: Network is unreachable
Trying recorded lease 192.168.1.214
connect: Network is unreachable
Trying recorded lease 192.168.1.51
connect: Network is unreachable
No working leases in persistent database - sleeping.
[  570.120826] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/00:e0:4c:f0:19:af
Sending on   LPF/wlan0/00:e0:4c:f0:19:af
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
[  572.108316] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 10.0.0.1
DHCPACK from 10.0.0.1
bound to 10.0.0.15 -- renewal in 40793 seconds.
done.
root@orangepiplus:~#

Debian 7 纯命令行 wlan设置
2013-09-15 23:00:35| 分类: Linux | 标签:linux 命令行 wifi |举报|字号 订阅

下载LOFTER我的照片书 | 1、Ethernet设置 因为在配置过程中,可能需要下载软件什么的,所有先连上有线网‘ 很简单 vi /etc/network/interfaces

######################## auto eth0 iface eth0 inet dhcp ########################

/etc/init.d/networking restart

这里用的是dhcp自动分配ip地址

2、配置wlan 装驱动,这个不说了,根据实际情况

iwconfig wlan0 txpower on ifconfig wlan0 up iwlist scanning 找到essid

apt-get install wpasupplicant

wpa_passphrase|tee /etc/wpa_supplicant.conf 这里会输入essid 和 password 生成的内容通过tee写入.conf文件

vi /etc/wpa_supplicant.conf

######################## network={ ssid="xxx" key_mgmt=WPA-PSK psk="xxx" proto=RSN pairwise=CCMP TKIP group=CCMP TKIP } ########################

wpa_supplicant -iwlan0 -Dwext -c/etc/wpa_supplicant.conf

vi /etc/network/interfaces

######################## auto wlan0 iface wlan0 inet dhcp wpa-ssid " xxxx " wpa-psk " xx " ########################

ifconfig wlan0 up /etc/init.d/networking restart

root@linaro-alip:/# vim /etc/network/interfaces

打开这个文件,把其中倒数第2行的 ssid 替换成你要用的无线网络名称,password 替换成该无线网络的密码

auto wlan0 iface wlan0 inet dhcp pre-up ip link set wlan0 up pre-up iwconfig wlan0 essid ssid wpa-ssid ssid wpa-psk password

举个例子,我的无线网络名称叫 Caesar-AP,密码是 test0000,那我的配置文件应该写成:

iface wlan0 inet dhcp pre-up ip link set wlan0 up pre-up iwconfig wlan0 essid ssid wpa-ssid Caesar-AP wpa-psk test0000

3、启用无线网线,执行系列命令,无线网卡会按照我们配置文件里面的信息自动连接该无线网络,并且每次重启电脑后仍然可以自动连接。

root@linaro-alip:/# ifup wlan0

改成这样,去掉wpa那个conf,然后reboot

auto wlan0  
allow-hotplug wlan0  
iface wlan0 inet dhcp  
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf  
# Disable power saving on compatible chipsets (prevents SSH/connection dropouts  
over WiFi)  
#wireless-mode Managed  
#wireless-power on  
wpa-ssid "TP-LINK_whg2"  
wpa-psk f0a597f0e82976c8ba3b6e607d6150f9895410f52bbd3b645e995a7ed32ea9aa  

  • 重启后还不行,dhclient wlan0 这样才有了IP 地址
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment