我正在试验 Raspberry Pi 3 Model B(运行 arch Linux)及其 WLAN 模块。
直到今天,我的整个网络都在它上面运行 Pi Hole。 Pi 所在的地方手机 Wifi 接收非常差,所以我决定在 Pi 上添加 Wifi AP。
现在奇怪的是 WLAN AP 工作正常(设置为桥接模式,如@所述)https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md)但我无法再向 Pi 发出 DNS 请求。
dig pi.home @192.168.1.150
; <<>> DiG 9.13.5 <<>> pi.home @192.168.1.150
;; global options: +cmd
;; connection timed out; no servers could be reached
更令人困惑的是,一旦我在 Chrome 中加载 Pi Hole Web 界面一次,DNS 就会再次工作。
我目前有以下配置。
Pi-Hole 的 DNS 服务器监听所有接口
桥接配置
cat /etc/netctl/bridge
Description="WAP Bridge"
Interface=br0
Connection=bridge
BindsToInterfaces=(eth0 wlan0)
IP=no
ExecUpPost="ip link set dev br0 address $(cat /sys/class/net/eth0/address); IP=dhcp; ip_set"
ExecDownPre="IP=dhcp"
SkipForwardingDelay=yes
iptables
cat /etc/iptables/iptables.rules
*nat
:PREROUTING ACCEPT [4:196]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [88:10291]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [31:4764]
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
COMMIT
如果配置
ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.150 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 xyxyxy prefixlen 64 scopeid 0x20<link>
ether xyxyxy txqueuelen 1000 (Ethernet)
RX packets 2537 bytes 468919 (457.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 267 bytes 60665 (59.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet6 xyxyxy prefixlen 64 scopeid 0x20<link>
ether xyxyxy txqueuelen 1000 (Ethernet)
RX packets 2560 bytes 473036 (461.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 297 bytes 70500 (68.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 109 bytes 8338 (8.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 109 bytes 8338 (8.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet6 xyxyxy prefixlen 64 scopeid 0x20<link>
ether xyxyxy txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2276 bytes 529781 (517.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
IPv4转发
cat /etc/sysctl.d/ipv4forwarding.conf
net.ipv4.ip_forward = 1
/etc/dhcpd.conf 包含
[...]
denyinterfaces eth0
denyinterfaces wlan0
/etc/hotapd/hostapd.conf(如果需要)
cat /etc/hostapd/hostapd.conf
interface=wlan0
bridge=br0
driver=nl80211
ssid=<SSID>
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=<PASSWORD>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
有人有想法吗?这是否与 Pi Hole 的 DNS 设置中的“允许所有来源”有关?
答案1
解决方案是添加Gateway
和br0
删除 IPv4 转发以及所有iptables
规则。