工作在AP模式就需要有线网卡和无线网卡进行桥接,这就要求我们首先要建立一个桥接接口。 使用 nmcli 命令来配置:首先使用 ip link 命令就可以看到哪些本机已经识别是网卡名称:
1
ip link
1
2
3
4
5
6
7
[iyunv@server ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: p2p1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether 00:14:78:66:2e:a7 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 90:94:e4:78:49:b5 brd ff:ff:ff:ff:ff:ff
[iyunv@server ~]# systemctl status hostapd
● hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Loaded: loaded (/etc/systemd/system/hostapd.service; enabled)
Active: failed (Result: exit-code) since 一 2015-09-21 20:19:49 CST; 3s ago
Process: 6897 ExecStart=/usr/sbin/hostapd /etc/hostapd/hostapd.conf -P /run/hostapd.pid $OTHER_ARGS (code=exited, status=1/FAILURE)
Main PID: 6897 (code=exited, status=1/FAILURE)
9月 21 20:19:49 server hostapd[6897]: wlp2s0: interface state HT_SCAN->DISABLED
9月 21 20:19:49 server hostapd[6897]: wlp2s0: AP-DISABLED
9月 21 20:19:49 server hostapd[6897]: wlp2s0: Unable to setup interface.
9月 21 20:19:49 server hostapd[6897]: wlp2s0: interface state DISABLED->DISABLED
9月 21 20:19:49 server hostapd[6897]: wlp2s0: AP-DISABLED
9月 21 20:19:49 server hostapd[6897]: hostapd_free_hapd_data: Interface wlp2s0 wasn't started
9月 21 20:19:49 server hostapd[6897]: nl80211: deinit ifname=wlp2s0 disabled_11b_rates=0
9月 21 20:19:49 server systemd[1]: hostapd.service: main process exited, code=exited, status=1/FAILURE
9月 21 20:19:49 server systemd[1]: Unit hostapd.service entered failed state.
9月 21 20:19:49 server systemd[1]: hostapd.service failed.
上面实际上看不出任何问题的具体细节。
6、hostapd 调试先看看 man hostapd 的手册了解一下如何进行调试。
1
man hostapd
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@server ~]# man hostapd
……省略……
hostapd [-hdBKtv] [-P <PID file>] <configuration file(s)>
-h Show usage.
-d Show more debug messages. #调试选项
-dd Show even more debug messages. #调试选项详细输出
-B Run daemon in the background.
-P <PID file> Path to PID file.
-K Include key data in debug messages.
-t Include timestamps in some debug messages.
-v Show hostapd version.
……省略……
看样子很简单大致就是上面的内容。那接下来以调试模式运行。
1
/usr/sbin/hostapd /etc/hostapd/hostapd.conf -d
1
2
3
4
5
[iyunv@server ~]# /usr/sbin/hostapd /etc/hostapd/hostapd.conf -d
……省略……
Could not set interface wlp2s0 flags (UP): Operation not possible due to RF-kill
nl80211: Failed to set interface up after switching mode
……省略……
坑提示:“Operation not possible due to RF-kill”,那么 RF-kill 又是什么呢?关于 RF-kill 可以看看这篇《rfkill 无线设备软开关》。
好吧,先安装 rfkill 软件包。
1
yum install rfkill
看看无线网卡是否被关掉了
1
rfkill list
1
2
3
4
[iyunv@server ~]# rfkill list
0: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no