Raspberry Pi 3 Model B+ 改造无线AP
环境
- Raspbian Stretch
安装hostapd和dnsmasq
更新系统
1 2 |
sudo apt-get update sudo apt-get upgrade |
安装组件
1 2 |
sudo apt-get install hostapd sudo apt-get install dnsmasq |
停止服务
1 2 |
sudo systemctl stop hostapd sudo systemctl stop dnsmasq |
配置DHCP
1 |
sudo nano /etc/dhcpcd.conf |
在末尾添加
1 2 3 4 |
interface wlan0 static ip_address=192.168.0.10/24 denyinterfaces eth0 denyinterfaces wlan0 |
配置DNSMASQ
1 2 |
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf |
文件写入
1 2 |
interface=wlan0 dhcp-range=192.168.0.11,192.168.0.30,255.255.255.0,24h |
配置hostapd
1 |
sudo nano /etc/hostapd/hostapd.conf |
写入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
interface=wlan0 bridge=br0 hw_mode=g channel=7 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP ssid=rasp-ap wpa_passphrase=yourpassword |
修改
1 |
sudo nano /etc/default/hostapd |
写入
1 |
DAEMON_CONF="/etc/hostapd/hostapd.conf" |
配置转发
编辑
1 |
sudo nano /etc/sysctl.conf |
增加
1 |
net.ipv4.ip_forward=1 |
配置iptables
1 |
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
保存
1 |
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" |
开机加载
1 |
iptables-restore < /etc/iptables.ipv4.nat |
桥接网卡
安装bridge-utils
1 |
sudo apt-get install bridge-utils |
建立桥接
1 |
sudo brctl addbr br0 |
配置桥接
1 |
sudo brctl addif br0 eth0 |
配置网卡
1 |
sudo nano /etc/network/interfaces |
写入
1 2 3 4 5 6 |
auto lo auto eth0 auto br0 iface br0 inet manual bridge_ports eth0 wlan0 |
重启
1 |
sudo reboot |
Know More
https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/
There are no comments yet