在 Raspberry Pi 上使用 Ubuntu 服务器设置接入点

在 Raspberry Pi 上使用 Ubuntu 服务器设置接入点

我想设置我的 Ubuntu 服务器来创建一个 Wi-Fi 网络,人们可以连接到该网络并打开本地网页。创建的 Wi-Fi 网络不得提供互联网访问并且只应允许访问本地网页。

然而,有必要的是Ubuntu 服务器,在树莓派上运行,有权访问到互联网。

这张图表阐明了我的要求:

                                 |
                 wifi            |           wired            wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
            \             /      |     \             /
           (dhcp)   192.168.4.1  |    (dhcp)   192.168.50.1

我根本不知道如何才能实现这一点,如果能得到任何帮助/指导我将非常感谢。

我的系统信息/硬件规格:

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:        18.04
Codename:       bionic

ubuntu
    description: Computer
    product: Raspberry Pi 3 Model B Plus Rev 1.3
    serial: 000000006d462490
    width: 64 bits
    capabilities: smp cp15_barrier setend swp
  *-core
       description: Motherboard
       physical id: 0
     *-cpu:0
          description: CPU
          product: cpu
          physical id: 0
          bus info: cpu@0
          size: 1400MHz
          capacity: 1400MHz
          capabilities: fp asimd evtstrm crc32 cpuid cpufreq
     *-cpu:1
          description: CPU
          product: cpu
          physical id: 1
          bus info: cpu@1
          size: 1400MHz
          capacity: 1400MHz
          capabilities: fp asimd evtstrm crc32 cpuid cpufreq
     *-cpu:2
          description: CPU
          product: cpu
          physical id: 2
          bus info: cpu@2
          size: 1400MHz
          capacity: 1400MHz
          capabilities: fp asimd evtstrm crc32 cpuid cpufreq
     *-cpu:3
          description: CPU
          product: cpu
          physical id: 3
          bus info: cpu@3
          size: 1400MHz
          capacity: 1400MHz
          capabilities: fp asimd evtstrm crc32 cpuid cpufreq
     *-memory
          description: System memory
          physical id: 4
          size: 912MiB
  *-usbhost
       product: DWC OTG Controller
       vendor: Linux 4.15.0-1041-raspi2 dwc_otg_hcd
       physical id: 1
       bus info: usb@1
       logical name: usb1
       version: 4.15
       capabilities: usb-2.00
       configuration: driver=hub slots=1 speed=480Mbit/s
     *-usb
          description: USB hub
          product: USB 2.0 Hub
          vendor: Standard Microsystems Corp.
          physical id: 1
          bus info: usb@1:1
          version: b.b3
          capabilities: usb-2.00
          configuration: driver=hub maxpower=2mA slots=4 speed=480Mbit/s
        *-usb:0
             description: USB hub
             product: USB 2.0 Hub
             vendor: Standard Microsystems Corp.
             physical id: 1
             bus info: usb@1:1.1
             version: b.b3
             capabilities: usb-2.00
             configuration: driver=hub maxpower=2mA slots=3 speed=480Mbit/s
           *-usb
                description: Generic USB device
                vendor: Standard Microsystems Corp.
                physical id: 1
                bus info: usb@1:1.1.1
                version: 3.00
                capabilities: usb-2.10
                configuration: driver=lan78xx maxpower=2mA speed=480Mbit/s
        *-usb:1
             description: Keyboard
             product: USB Receiver
             vendor: Logitech
             physical id: 2
             bus info: usb@1:1.2
             version: 29.01
             capabilities: usb-2.00
             configuration: driver=usbhid maxpower=98mA speed=12Mbit/s
        *-usb:2
             description: Keyboard
             product: 2.4G Keyboard Mouse
             vendor: MOSART Semi.
             physical id: 3
             bus info: usb@1:1.3
             version: 81.13
             capabilities: usb-1.10
             configuration: driver=usbhid maxpower=100mA speed=12Mbit/s
  *-network:0 DISABLED
       description: Wireless interface
       physical id: 2
       logical name: wlan0
       serial: b8:27:eb:13:71:c5
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=brcmfmac driverversion=7.45.18 firmware=01-6a2c8ad4 multicast=yes wireless=IEEE 802.11
  *-network:1
       description: Ethernet interface
       physical id: 3
       logical name: eth0
       serial: b8:27:eb:46:24:90
       size: 1Gbit/s
       capacity: 1Gbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=lan78xx driverversion=1.0.6 duplex=full ip=10.0.0.92 link=yes multicast=yes port=MII speed=1Gbit/s

编辑:我正在使用 snap 创建接入点

我现在正在使用wifi-ap snap以便创建 wifi 网络。这很好用,但是我不知道如何按我想要的方式配置它(如上所述)。

谢谢您的帮助!

答案1

有一个折断正是这样做的。

我不知道是否可以配置接入点包来阻止您的网络客户端访问网络。但是,您始终可以iptables为此创建两个规则:

  1. 丢弃来自互联网、目的地不是服务器 IP 的数据包的规则;
  2. 一条规则,丢弃来自 LAN 并发往互联网的数据包,换句话说,目的地不是 192.168.*。

相关内容