树莓派+archlinuxarm做路由


1
pacman -S dnsmasq hostapd
1
2
ip link set dev wlan1 up
ip addr add 192.168.100.1/24 broadcast 192.168.100.255 dev wlan1
1
2
3
4
5
6
7
8
9
10
11
/etc/hostapd/hostapd.conf
interface=wlan1
driver=nl80211
ssid=ArchlinuxARM_RPI
hw_mode=g
channel=7
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
1
2
3
4
/etc/dnsmasq.conf
interface=wlan1
listen-address=192.168.100.1,127.0.0.1
dhcp-range=192.168.100.50,192.168.100.150,12h
1
2
systemctl start hostapd
systemctl start dnsmasq
1
2
3
4
echo "1" >/proc/sys/net/ipv4/ip_forward  
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -P FORWARD ACCEPT
iptables -F FORWARD

编辑成一个脚本

1
2
3
4
5
6
7
8
9
#!/bin/sh
ip link set dev wlan1 up
ip addr add 192.168.100.1/24 broadcast 192.168.100.255 dev wlan1
echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -P FORWARD ACCEPT
iptables -F FORWARD
systemctl start hostapd
systemctl start dnsmasq