在 Raspberry Pi 上连接多个接口

在 Raspberry Pi 上连接多个接口

我使用 raspi 作为本地 DNS 解析器 (Pi-hole)。我的路由器有 2 个网络“家庭”和“访客”。像往常一样,访客客户端无法访问我的 raspi,因为它在家庭网络上,因此互联网对访客客户端不起作用。因此,我插入了一个 USB wifi 适配器,将其连接到访客网络,以便它可以从那里与访客客户端通信。但问题是,在设置 Netplan 后,它连接到访客网络,但出于某种原因,我可以从家庭网络 ping raspi 的访客 IP,访客客户端仍然无法访问它。我的路由器可以通过家庭网络 IP 看到它!!需要帮助来解决这个问题,新手在这里。

信息:

Home Network: | Interface: eth0 | IP: 192.168.68.104

Guest Network: | Interface: wlan0 | IP: 192.168.68.204

/etc/netplan/50-cloud-init.yaml:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: false
      addresses: [192.168.68.104/24]
      routes:
       - to: default
         via: 192.168.68.1
         metric: 200
      nameservers:
        addresses: [127.0.0.1]
  wifis:
    wlan0:
      dhcp4: false
      addresses: [192.168.68.204/24]
      routes:
       - to: default
         via: 192.168.68.1
         metric: 300
      nameservers:
        addresses: [127.0.0.1]
      access-points:
          "Guest Network Name":
              password: "Guest Password"

ifconfig:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.68.104  netmask 255.255.255.0  broadcast 192.168.68.255
        inet6 fe80::ba27:ebff:fe3c:bddd  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:3c:bd:dd  txqueuelen 1000  (Ethernet)
        RX packets 391049  bytes 44256085 (44.2 MB)
        RX errors 0  dropped 7  overruns 0  frame 0
        TX packets 357415  bytes 41832959 (41.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 2312
        inet 192.168.68.204  netmask 255.255.255.0  broadcast 192.168.68.255
        inet6 fe80::523e:aaff:fe6c:6966  prefixlen 64  scopeid 0x20<link>
        ether 50:3e:aa:6c:69:66  txqueuelen 1000  (Ethernet)
        RX packets 20534  bytes 2926374 (2.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2567  bytes 265318 (265.3 KB)
        TX errors 0  dropped 7 overruns 0  carrier 0  collisions 0

IP 路由列表:

default via 192.168.68.1 dev eth0 src 192.168.68.104 metric 202 
default via 192.168.68.1 dev wlan0 proto dhcp src 192.168.68.112 metric 303
192.168.68.0/24 dev eth0 proto dhcp scope link src 192.168.68.104 metric 202 
192.168.68.0/24 dev wlan0 proto dhcp scope link src 192.168.68.112 metric 303

路由器 DHCP 服务器设置: 路由器 DHCP 截图

相关内容