博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【树莓派】树莓派配置无线网络访问
阅读量:5916 次
发布时间:2019-06-19

本文共 4747 字,大约阅读时间需要 15 分钟。

树莓派无线配置,之前有写过,但是总有人搞不清楚,现在我再把3份文件保存在这里,供参考;

下面包含三种配置:

interfaces  interfaces.wlan0.dhcp  interfaces.wlan0.static

 

看其中内容:

interfaces.default

# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto loiface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0iface wlan0 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

  

interfaces.wlan0.dhcp

# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto loiface lo inet loopbackiface eth0 inet manual#allow-hotplug wlan0#iface wlan0 inet manual#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confauto wlan0  allow-hotplug wlan0  iface wlan0 inet dhcp          wpa-ssid "Wingspan-Working"          wpa-psk  "wingspan" allow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

  

 

interfaces.wlan0.static

# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto loiface lo inet loopbackiface eth0 inet manual#allow-hotplug wlan0#iface wlan0 inet manual#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confauto wlan0allow-hotplug wlan0iface wlan0 inet static  wpa-ssid "Wingspan-Working"  wpa-psk "wingspan"  address 192.168.11.80  netmask 255.255.255.0  gateway 192.168.11.1allow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

  

 之前的方式只是一种,而且并不是很稳定,不能配置多个WIfi链接

下面的方法可以配置多个Wifi连接:

lifeccp@raspberrypi:~ $ cat /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.d#auto loauto lo wlan0 wlan1iface lo inet loopbackiface eth0 inet dhcpauto wlan0allow-hotplug wlan0iface wlan0 inet dhcpwpa-conf /etc/wpa_supplicant/wpa_supplicant.conf#wpa-conf /etc/wpa.conf#iface default inet dhcp#    wpa-ssid "Wingspan-Guest"#    wpa-psk "wingspanwifi"allow-hotplug wlan1iface wlan1 inet manual#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

文件2:

/etc/wpa_supplicant/wpa_supplicant.conf

country=GBctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1network={ssid="test"psk="12348765"}network={ssid="hao"psk="00009999"}network={ssid="WingSpan-Guest"psk="wingspanwifi"}

 

搜索附近可用的无线网络:

lifeccp@raspberrypi:~ $ sudo iwlist wlan0 scan | grep ESSID[sudo] password for lifeccp:                     ESSID:"HaoChuang-Guest"                    ESSID:"HaoChuang-dispaly"                    ESSID:"HaoChuang-Guest"                    ESSID:"HaoChuang-Guest"                    ESSID:"mac\xE7\x9A\x84MacBook Pro"

当然,配置的时候,如果有疑问,也可以参考其他的配置文档:

玩转树莓派-Raspberry,无线网配置方法:

树莓派连接WiFi:

树莓派连接WiFi(最稳定的方法):

树莓派 Raspberry Pi 设置无线上网:

 

---------------补充-------------- 

树莓派配置无线静态IP地址

修改文件: /etc/network/interfaces,命令如下

sudo vi /etc/network/interfaces

注释掉这两行

#iface wlan0 inet dhcp #    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

并补充如下信息,(或将最后一句 iface default inet dhcp,替换成):

iface wlan0 inet static    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confaddress 192.168.21.181netmask 255.255.255.0gateway 192.168.21.1dns-nameservers 61.134.1.4

 

则需要两个配置文件,分别如下:

/etc/network/interfaces:

auto loiface lo inet loopbackiface eth0 inet manual#pre-up ifconfig eth0 hw ether 00:9a:9b:96:6a:7cauto eth2iface eth2 inet manualauto wlan0allow-hotplug wlan0iface wlan0 inet static    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confaddress 192.168.21.181netmask 255.255.255.0gateway 192.168.21.1dns-nameservers 61.134.1.4#iface wlan0 inet dhcp #    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf#allow-hotplug wlan0#iface wlan0 inet manual#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf:
country=GBctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1network={ ssid="WingSpan-Guest" psk="wingspanwifi"}network={  ssid="tozed-1CA8D5"  psk="691065DA"}

 修改之后保存退出,然后重启网络:

sudo /etc/init.d/networking restart

即可见结果为静态IP:

 

 

 

 

待续。。。

转载地址:http://wtgpx.baihongyu.com/

你可能感兴趣的文章
CentOS下基于PPTPD与AD验证的×××服务器构建
查看>>
Java中的回调函数
查看>>
[每日一题] OCP1z0-047 :2013-07-21 子查询――多字段的顺序..............................................10...
查看>>
php加载模块
查看>>
在.net中读写config文件的各种方法
查看>>
如何正确对待和处理Windows更新问题?
查看>>
arcgis 拒绝访问 temp 目录
查看>>
[转]集中式日志系统 ELK 协议栈详解
查看>>
百度理解与交互技术 UNIT access_token获取接口
查看>>
linux重定向命令
查看>>
我的友情链接
查看>>
信号记录
查看>>
linux基础入门shell基础特性
查看>>
初步探索Linux(3)
查看>>
Linux下su与su -命令的本质区别
查看>>
硬盘与分区
查看>>
cacit下apache模版安装和使用
查看>>
Ubuntu Server 语言环境变量改为英文
查看>>
数据库存储图片读取
查看>>
企业级nginx.conf优化参考模板
查看>>