Linux下面无线网络配置
包括内核的支持、用户层配置工具和驱动接口的支持三部分。目前很多无线网卡都支持LWE,而且主流的Linux发布版本,比如Redhat Linux、Ubuntu Linux都已经带了这个配置工具。
用法: iwconfig interface [essid {NN|on|off}]
[nwid {NN|on|off}]
[mode {managed|ad-hoc|...}
[freq N.NNNN[k|M|G]]
[channel N]
[ap {N|off|auto}]
[sens N]
[nick N]
[rate {N|auto|fixed}]
[rts {N|auto|fixed|off}]
[frag {N|auto|fixed|off}]
[enc {NNNN-NNNN|off}]
[power {period N|timeout N}]
[retry {limit N|lifetime N}]
[txpower N {mW|dBm}]
[commit]
参数:
essid:设置无线网卡的ESSID(Extension Service Set ID)。通过ESSID来区分不同的无线网络,正常情况下只有相同ESSID的无线站点
才可以互相通讯,除非想监听无线网络。其后的参数为双引号括起的ESSID字符串,或者是any/on/off,如果ESSID字符串中包含
any/no/off,则需要在前面加"--"。
示例:
#iwconfig eth0 essid any 允许任何ESSID,也就是混杂模式
#iwconfig eth0 essid "My Network" 设置ESSID为"My Network"
#iwconfig eth0 essid -- "ANY" 设置ESSID为"ANY"
#iwpriv eth0 auth 2 设置认证方式为Shared
iwconfig eth0 nwid o
iwconfig eth0 nickname “My Linux Node”
iwconfig eth0 txpower off
iwconfig eth0 rts 250
iwconfig eth0 rts off
iwconfig eth0 mode Managed
iwconfig eth0 mode Ad-Hoc
iwconfig eth0 freq 2422000000
iwconfig eth0 freq 2.422G
iwconfig eth0 channel 3
iwconfig eth0 channel auto
iwconfig eth0 ap 00:60:1D:01:23:45
iwconfig eth0 ap any
iwconfig eth0 ap off
iwconfig eth0 rate 11M
iwconfig eth0 rate auto
iwconfig eth0 rate 5.5M auto
iwconfig eth0 txpower 15
iwconfig eth0 txpower 30mW
iwconfig eth0 txpower auto
iwconfig eth0 txpower off
iwconfig eth0 sens -80
iwconfig eth0 sens 2
iwconfig eth0 retry 16
iwconfig eth0 retry lifetime 300m
iwconfig eth0 retry min limit 8
示例:
#iwconfig eth0 nwid AB34
#iwconfig eth0 nwid off
nick: Nickname,一些网卡需要设置该参数,但是802.11协议栈、MAC都没有用到该参数,一般也不用设置。
示例:
#iwconfig eth0 nickname "My Linux Node"
mode:设置无线网卡的工作模式,可以是
Ad-hoc:不带AP的点对点无线网络
Managed:通过多个AP组成的网络,无线设备可以在这个网络中漫游
Master:设置该无线网卡为一个AP
Repeater:设置为无线网络中继设备,可以转发网络包
Secondary:设置为备份的AP/Repeater
Monitor:监听模式
Auto:由无线网卡自动选择工作模式
示例:
#iwconfig eth0 mode Managed
#iwconfig eth0 mode Ad-Hoc
freq/channel:设置无线网卡的工作频率或者频道,小于1000的参数被认为是频道,大于10000的参数被认为是频率。频率单位为Hz,
可以在数字后面附带k, M, G来改变数量级,比如2.4G。频道从1开始。使用lwlist工具可以查看无线网卡支持的频率
和频道。参数off/auto指示无线网络自动挑选频率。
注意:如果是Managed模式,AP会指示无线网卡的工作频率,因此该设置的参数会被忽略。Ad-hoc模式下只使用该设定的频率初始无线网络,如果加入已经存在的Ad-hoc网络则会忽略该设置的频率参数。
示例:
#iwconfig eth0 freq 2422000000
#iwconfig eth0 freq 2.422G
#iwconfig eth0 channel 3
#iwconfig eth0 channel auto
一个已经存在的Ad-hoc网络。使用off参数让无线网卡不改变当前已连接的AP下进入自动模式。any/auto参数,无线网卡自动选择
最好的AP。
注意:如果无线信号低到一定程度,无线网络会进入自动选择AP模式。
示例:
#iwconfig eth0 ap 00:60:1D:01:23:45
#iwconfig eth0 ap any
#iwconfig eth0 ap off
率的索引值,大于1000的为速率,单位bps,可以在数字后面附带k, M, G来指定数量级。auto参数让无线网卡自动选择速率
fixed参数让无线网卡不使用自动速率模式。
示例:
#iwconfig eth0 rate 11M
#iwconfig eth0 rate auto
#iwconfig eth0 rate 5.5M auto //自动选择5.5M以下的速率
txpower:如果无线网卡支持多发射功率设定,则使用该参数设定发射,单位为dBm,如果指定为W(毫瓦),只转换公式为:
dBm=30+log(W)。参数on/off可以打开和关闭发射单元,auto和fixed指定无线是否自动选择发射功率。
示例:
#iwconfig eth0 txpower 15
#iwconfig eth0 txpower 30mW
#iwconfig eth0 txpower auto
#iwconfig eth0 txpower off
sens:设置接收灵敏度的下限,在该下限之下,无线网卡认为该无线网络信号太差,不同的网卡会采取不同的措施,一些现代的无线网卡
会自动选择新的AP。正的参数为raw data,直接传给无线网卡驱动处理,一般认为是百分比。负值表示dBm值。
示例:
#iwconfig eth0 sens -80
#iwconfig eth0 sens 2
retry:设置无线网卡的重传机制。limit ‘value’ 指定最大重传次数;lifetime ‘value’指定最长重试时间,单位为秒,可以附带m和u来
指定单位为毫秒和微秒。如果无线网卡支持自动模式,则在limit和lifetime之前还可以附加min和max来指定上下限值。
示例:
#iwconfig eth0 retry 16
#iwconfig eth0 retry lifetime 300m
#iwconfig eth0 retry min limit 8
rts:指定RTS/CTS握手方式,使用RTS/CTS握手会增加额外开销,但如果无线网络中有隐藏无线节点或者有很多无线节点时可以提高性能。
后面的参数指定一个使用该机制的最小包的大小,如果该值等于最大包大小,则相当于禁止使用该机制。可以使用auto/off/fixed
参数。
示例:
#iwconfig eth0 rts 250
#iwconfig eth0 rts off
frag:设置发送数据包的分片大小。设置分片会增加额外开销,但在噪声环境下可以提高数据包的到达率。一般情况下该参数小于最大包
大小,有些支持Burst模式的无线网卡可以设置大于最大包大小的值来允许Burst模式。还可以使用auto/fixed/off参数。
示例:
#iwconfig eth0 frag 512
#iwconfig eth0 frag off
key/enc[ryption]:设置无线网卡使用的加密密钥,此处为设置WEP模式的加密key,如果要使用WPA,需要wpa_supplicant工具包。
密钥参数可以是 XXXX-XXXX-XXXX-XXXX 或者 XXXXXXXX 格式的十六进制数值,也可以是s:xxxxxx的ASCII字符。如果在密钥参数之前
加了[index],则只是设置该索引值对应的密钥,并不改变当前的密钥。直接指定[index]值可以设置当前使用哪一个密钥。指定on/
off可以控制是否使用加密模式。open/restricted指定加密模式,取决于不同的无线网卡,大多数无线网卡的open模式不使用加密且
允许接收没有加密的数据包,restricted模式使用加密。可以使用多个key参数,但只有最后一个生效。
WEP密钥可以是40bit,用10个十六进制数字或者5个ASCII字符表示,也可以是128bit,用26个十六进制数字或者13个ASCII字符表
示。
#iwconfig eth0 key 0123-4567-89
#iwconfig eth0 key [3] 0123-4567-89
#iwconfig eth0 key s:password [2]
#iwconfig eth0 key [2]
#iwconfig eth0 key open
#iwconfig eth0 key off
#iwconfig eth0 key restricted [3] 0123456789
#iwconfig eth0 key 01-23 key 45-67 [4] key [4]
power:设置无线网卡的电源管理模式。period ‘value’ 指定唤醒的周期,timeout ‘value’指定进入休眠的等待时间,这两个参数之前可以
加min和max修饰,这些值的单位为秒,可以附加m和u来指定毫秒和微秒。off/on参数指定是否允许电源管理,all/unicast/multicast
指定允许唤醒的数据包类型。
示例:
#iwconfig eth0 power period 2
#iwconfig eth0 power 500m unicast
#iwconfig eth0 power timeout 300u all
#iwconfig eth0 power off
#iwconfig eth0 power min period 2 power max period 4
commit:提交所有的参数修改给无线网卡驱动。有些无线网卡驱动会先缓存无线网卡参数修,使用这个命令来让无线网卡的参数修改生效。不过一般不需要使用该命令,因为无线网卡驱动最终都会是参数的修改生效,一般在debug时会用到。
-------------------------------------------------------------------------
iwlist eth1 scan 搜索无线网络:
显示搜到的网络(此处只显示一个):
eth1 Scan completed :
Cell 01 - Address: 00:04:E2:E3:04:FC
ESSID:"ap_demo"
Mode:Managed
Frequency:2.437 GHz
Quality:0/0 Signal level=-61 dBm Noise level=-96 dBm
Encryption key:on
Bit Rate:1 Mb/s
Bit Rate:2 Mb/s
Bit Rate:5.5 Mb/s
Bit Rate:11 Mb/s
Bit Rate:6 Mb/s
Bit Rate:9 Mb/s
Bit Rate:12 Mb/s
Bit Rate:18 Mb/s
Bit Rate:24 Mb/s
Bit Rate:36 Mb/s
Bit Rate:48 Mb/s
Bit Rate:54 Mb/s
Cell 02 ……
iwlist eth1 channel 11
-----------------------------------------------------------------------------
设置模式:
iwconfig eth1 mode managed
通过MAC 设置AP:
iwconfig eth1 ap 00:0A:EB:CA:79:B0
iwconfig eth1 key s:12345 等效于 iwconfig eth1 enc 3132333435(12345的hex值) (为什么AP64bit的口令是40bit呢)
iwconfig eth1 key on
iwconfig eth1 essid sychip_demo
断开WEP:
iwconfig eth1 enc off
查看IP:
ifconfig eth1
设置IP:
ifconfig eth1 10.3.1.74
把IP: 129.158.215.204 , netmask: 255.255.255.0分配给rh0,
# ifconfig rh0 129.158.215.204 netmask 255.255.255.0
ifconfig eth1 dhcp start (从eth1走,不需要ip即可dhcp)
udhcpc -i eth1
udhcpc --help
路由处理:
若要删除以 10. 起始的 IP 路由表中的所有路由,请键入:
route delete 10.*
route del default
route add -net 10.3.0.0 netmask 255.255.0.0 eth1 (eth1获得IP之前,使用此命令显示:No such device)
Linux下面无线网络配置的更多相关文章
- Linux rhel7 无线网络配置
前言: 手提新装rhel7, ifconfig 发现只有lo 怎么办? 1. 检查网卡驱动装了没有: nmcli -a|grep wlp\ 如果没安装: a. lspci|grep Wireless ...
- linux无线网络配置_转
转自:http://www.cnblogs.com/dartagnan/archive/2010/12/05/2003521.html 一位资生linux 原文:http://www.hpl.hp ...
- 【转】Linux - CentOS 7网络配置
Linux - CentOS 7网络配置 https://blog.csdn.net/J080624/article/details/78083988 安装完VM后,需要进行网络配置.第一个目标为 ...
- Linux系统安装和网络配置
系统下载 CentOS 6.x 50% 6.9 ---- 常用 CentOS 7.x 50% 7.2 ----常用 官网-国外 https://wiki.centos.org/Downloa ...
- Linux系统基本网络配置之ifconfig命令
Linux系统基本网络配置之ifconfig命令 一.Linux系统的网络配置基本包括:网络IP的配置.网关路由的配置.主机DNS的配置.主机名的配置等,本篇注重介绍网络IP的配置. 二.Linux系 ...
- (转)Linux系统基础网络配置老鸟精华篇
Linux系统基础网络配置老鸟精华篇 原文:http://blog.51cto.com/oldboy/784625 对于linux高手看似简单的网络配置问题,也许要说出所以然来也并不轻松,因此仍然有太 ...
- Linux 7.X 网络配置
Linux 7.X 网络配置 环境: 笔记本中安装了虚拟机,在虚拟机中安装了Redhat 7.4版本的操作系统,现配置该操作系统网络.(IP.网关等) 相关指令如下: # nmcli connecti ...
- linux 无线网络配置工具wpa_supplicant与wireless-tools
4.a. 介绍目前您可以使用我们提供的wireless-tools 或wpa_supplicant工具来配置无线网络.请记住重要的一点是,您对无线网络的配置是全局性的,而非针对具体的接口.wpa_su ...
- Linux之Ubuntu无线网络配置
无线网络使用问题: 0.插上有线网络电线与电脑NIC上. 1.set->系统设置->软件和更新->Ubuntu软件->下载自: 选择一个网络服务器地址(软件源)[http: ...
随机推荐
- jmeter如何连接数据库
大家都知道jmeter是java编写的,java/jmeter如果想连接数据库就要通过java database connector(JDBC)去连接,首先需先下载一个驱动 (mysql-connec ...
- Assetbundle2
Assetbundle可以将Prefab封装起来,这是多么方便啊! 而且我也强烈建议大家将Prefab封装成Assetbundle,因为Prefab可以将游戏对象身上带的游戏游戏组件.游戏脚本.材质都 ...
- [nginx] OpenResty 学习手册
OpenResty Installation Find tar.gz : https://openresty.org/cn/download.html tar -xzvf openresty-VERS ...
- SpringBoot:工厂模式实现定时任务可配置
pringBoot:工厂模式实现定时任务可配置 需要:使用springboot,实现定时任务可配置. 定时任务可在代码中写死,在配置文件中配置,这些都不能实现定时任务在服务器不重启的情况下可配置. 为 ...
- ubuntu 和 centOS 的apache设置
更改ubuntu的网站访问根目录: 在sudo gedit /etc/apache2/sites-enabled/000-default,把 DocumentRoot /var/www #这 ...
- Android之ViewPager 第一课
想要了解Android新版本的的新特性,从头开始吧,这是Android3.0新加入的widget,以前也接触过,但是没有好好的研究过,今天写了一个小程序,研究一下ViewPager. 这个程序是支持左 ...
- HDU 1028 整数拆分问题 Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- ArcGIS Server中创建的两个账户有什么区别
新手常常有这样的疑问: 在安装ArcGIS Server的时候创建的账户和在ArcGIS Server Manager上面创建的账户有什么区别? 解答:前者是是为ArcGIS Server创建的操作系 ...
- ArcGIS Engine开发中利用GP工具时常出现的错误
在用GP工具的时候常常会碰到这个错误: 调用 GP 对 COM 组件的调用返回了错误 HRESULT E_FAIL 解决方案: 这种情况一般有两种可能. 1.AE程序的license的级别不够. 2. ...
- 第四次JAVA作业
public class TvbDog { public static void main(String[] args) { Dog per=new Dog("陈狗"," ...