创建一个接入点以在两个无线连接之间“桥接”。 /etc/network/interfaces 应该是什么样子?

创建一个接入点以在两个无线连接之间“桥接”。 /etc/network/interfaces 应该是什么样子?

我正在遵循本指南:将 Raspberry Pi 设置为独立网络 (NAT) 中的接入点创建一个接入点。唯一的区别是我使用的是另一个 wifi 连接,而不是以太网连接,所以我只是在整个教程中进行了更改,因为eth0我的 USB 加密狗连接到了我的路由器。wlan1wlan1

但是,没有提及该/etc/network/interfaces文件。这是我的:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

我可以看到 SSID 并连接到它,但它会永远获取 IP 地址。我认为这与/etc/network/interfaces.看看我的ifconfig

pi@raspberrypi:~ $ ifconfig 
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 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.25.6  netmask 255.255.255.0  broadcast 192.168.25.255
        inet6 fe80::ba27:ebff:feaa:1f8  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:aa:01:f8  txqueuelen 1000  (Ethernet)
        RX packets 42  bytes 5757 (5.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 37  bytes 5838 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.25.6  netmask 255.255.255.0  broadcast 192.168.25.255
        inet6 2804:7f0:e181:b678:2e0:4dff:fe06:4f8  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::2e0:4dff:fe06:4f8  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:4d:06:04:f8  txqueuelen 1000  (Ethernet)
        RX packets 86  bytes 11978 (11.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 15855 (15.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

怎么能wlan0有IP192.168.25.6呢?这是连接的路由器给出的 IP wlan1

我应该如何编辑wlan0配置?我一直在尝试很多静态配置,但是当我做任何与屏幕上显示的不同的事情时,板载 wifi 接口就会消失,然后 USB 适配器取代了wlan0

另外,有没有办法保证USB适配器始终能连接到wlan1板载wifi wlan0?看起来很随意。

更新

● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: failed (Result: exit-code) since Sun 2018-08-05 04:54:32 UTC; 7s ago
  Process: 853 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=6)

Aug 05 04:54:32 raspberrypi systemd[1]: Starting dhcpcd on all interfaces...
Aug 05 04:54:32 raspberrypi dhcpcd[853]: Not running dhcpcd because /etc/network/interfaces
Aug 05 04:54:32 raspberrypi dhcpcd[853]: defines some interfaces that will use a
Aug 05 04:54:32 raspberrypi dhcpcd[853]: DHCP client or static address
Aug 05 04:54:32 raspberrypi systemd[1]: dhcpcd.service: Control process exited, code=exited status=6
Aug 05 04:54:32 raspberrypi systemd[1]: Failed to start dhcpcd on all interfaces.
Aug 05 04:54:32 raspberrypi systemd[1]: dhcpcd.service: Unit entered failed state.
Aug 05 04:54:32 raspberrypi systemd[1]: dhcpcd.service: Failed with result 'exit-code'.

答案1

如果wlan0它将成为接入点 (AP),那么您不应尝试将其用作客户端(站、STA)。但这就是

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

说:“请wlan0在客户端模式下使用,并使用 DHCP 为其获取 IP 地址”。相反,你想要类似的东西

auto wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.255

将网络掩码替换10.0.0.*为您希望 AP 具有的 IP 范围。

相关内容