Ubuntu Server 22.04 如何创建 WiFi 接入点?

Ubuntu Server 22.04 如何创建 WiFi 接入点?

如何才能学会使用 Ubuntu Server 22.04 创建 WiFi AP?谷歌搜索这些关键词,会发现针对旧版本 Ubuntu Server 的冲突和过时的说明。

我尝试过几个“如何做”页面,但似乎没有什么作用。

答案1

希望这可以帮助:

这是我在 Raspberry Pi 3 Model B+ 上创建无线热点的方法。此配置不提供 IP 地址,因此您需要网络上的某个位置有 DHCP 服务器才能使其工作。这是 IPV4 特定的,并且 Pi 在网络上有一个静态地址。我还在网络的其他地方设置了一个本地 DNS 服务器,它提供有关本地私有域的信息,这就是为什么我在 Netplan [yourlocaldomain.lan] 中有一个搜索域条目。如果您没有该条目,则不需要该条目,但您仍然需要添加 DNS 服务器的条目。

wifi 配置是为在澳大利亚使用而设置的,因此您必须针对其他国家/地区进行编辑。下面所有以“您的”开头的条目...您需要输入与您自己的网络一致的数据。例如,yourStaticAddressofPi 可以变成 192.168.3.50。在这种情况下,yournetmask 将是 24。

我使用图像进行了安装ubuntu-22.04-preinstalled-server-arm64+raspi.img.xz。然后应用所有当前更新,即 sudo apt update、sudo apt upgrade、sudo reboot。

然后我安装了 hostapd 和 wpa_supplicant。(sudo apt install hostapd、sudo apt install wpa_supplicant、sudo reboot)。Hostapd 配置(位于 /etc/hostapd/hostapd.conf):

ctrl_interface=/var/run/hostapd
###############################
# Basic Config
###############################
macaddr_acl=0
auth_algs=1
country_code=AU
require_ht=0
#ht_capab= [HT40+] [HT40-] [SHORT-GI-40] [RX-STBC1]
#ieee80211d=1
#ieee80211n=1
wmm_enabled=1

# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211
##########################
# Local configuration...
##########################
interface=wlan0
bridge=br0
hw_mode=g
channel=1
ssid=yourssid
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=yourpassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

netplan 配置(/etc/netplan/50-cloud-init.yaml)如下:

#persistent config
network:
    version: 2
    ethernets:
       eth0:
          dhcp4: false
          dhcp6: false
       wlan0:
          dhcp4: false
          dhcp6: false
    bridges:     
        br0:
          interfaces: [eth0,wlan0]
          addresses: [yourStaticAddressofPi/yournetmask]
          routes:
            - to: default
              via: yourdefaultgatewayaddress
          mtu: 1500
          nameservers:
            search: [yourlocaldomain.lan]
            addresses: [yourIP4addressforDNSserver]
          dhcp4: no
          dhcp6: no

然后我还编辑了 sysctl.conf (/etc/sysctl.conf):取消注释net.ipv4.ip_forward=1 这将启用跨网络适配器的 IPV4 数据包路由。然后添加了以下几行:

#Disable IP6 entirely
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.eth0.disable_ipv6=1

完成所有这些更改并重新启动后,Pi 应该可以在静态地址上使用,并且 WiFi 应该可以连接。注意:Pi 3 Model B+ 需要一段时间才能启动所有服务(至少几分钟),因此您需要耐心等待。

相关内容