要给这个无线网卡分配一个固定 IP 令其为192.168.9.1。
1,更改/etc/network/interfaces。增加对于WLAN0(默认这个虚拟无线网卡是wlan0)的固定配置(以后插的无线网卡是wlan1)。
原有代码为
----------------
auto lo
iface lo inet loopback
-----------------------------------
添加下面代码
----------------------------------
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.60
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.9.1
netmask 255.255.255.0
---------------------------------
2,修改/etc/hostapd/hostapd.conf
最后加上
-----------------------------------------
ssid=testwifi
wpa_passphrase=123456
----------------------------------------------
wpa=2
channel=1
interface=wlan0
bridge=br0
driver=nl80211
hw_mode=g
channel=11
dtim_period=1
rts_threshold=2347
fragm_threshold=2346
auth_algs=3
wpa=1
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
3,修改/etc/udhcpd.conf
把ip里面8改成9
---------------------------
start 192.168.9.20
end 192.168.9.254
opt dns 192.168.9.1 8.8.8.8
opt router 192.168.9.1
opt wins 192.168.9.1
------------------------------
4,修改/etc/default/udhcpd,修改dhcpd功能为yes。
DHCPD_ENABLE="yes"
5,设置hostapd和udhcpd服务
sudo systemctl enable hostapd
sudo systemctl enable udhcpd.service
6,重启