将有线接口桥接到无线接口时出现问题

发布于 2024-08-02 16:49:19 字数 1446 浏览 5 评论 0原文

我正在做与大多数人在桥接以太网和无线接口时所做的相反的事情。我有一个没有无线卡的盒子,我想通过旁边有无线卡和以太网卡的盒子提供对互联网的访问。无线网卡通过无线路由器访问互联网,无线路由器作为专用网络192.168.0.*上的dhcp服务器。路由器的 dhcp 服务器配置为从不分配以下任何静态 IP 地址。

我已经在 /etc/network/interfaces 中配置了网桥,并且当我启动 br0 时没有报告任何问题。问题是,桥接后,两台计算机都无法访问互联网。以下是我的配置详细信息:

/etc/network/interfaces:

allow-hotplug eth0
iface eth0 inet static
  address       192.168.0.15
  netmask       255.255.255.0
  broadcast     192.168.0.255

auto wlan0
iface wlan0 inet dhcp
pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

iface br0 inet static
  gateway 192.168.0.1
  address 192.168.0.10
  netmask 255.255.0.0
  broadcast 192.168.0.255
  network 192.168.0.0
  bridge_ports wlan0 eth0
  pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

单独使用时,无线连接工作正常,路由如下所示:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     1000   0        0 wlan0
default         localhost       0.0.0.0         UG    0      0        0 wlan0

当我启动 br0 时,路由表是相同的,但每个条目的 Iface 是br0,并且需要大量时间才能返回“默认”条目。

我注意到的另一个区别是,当我使用 ifconfig 列出接口时,wlan0 在启动 br0 后不再显示 IP 地址。

尝试 ping 路由器 (192.168.0.1) 或公共互联网地址时返回的错误是: 来自 br0 的 IP 的“目标主机无法访问”:192.168.0.10。

有什么想法吗?

谢谢, 吉万

I'm doing the reverse of what it seems most people do when bridging an ethernet and wireless interface. I have one box without a wireless card, and I want to provide access to the internet through the box next to it which has both a wireless card and an ethernet card. The wireless card accesses the internet through a wireless router which serves as the dhcp server on the private network 192.168.0.*. The router's dhcp server is configured to never assign any of the static ip address below.

I've configured the bridge in /etc/network/interfaces, and no problems are reported when I bring up br0. The problem is that after bringing up the bridge, neither computer can access the internet. Here are the details of my configuration:

/etc/network/interfaces:

allow-hotplug eth0
iface eth0 inet static
  address       192.168.0.15
  netmask       255.255.255.0
  broadcast     192.168.0.255

auto wlan0
iface wlan0 inet dhcp
pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

iface br0 inet static
  gateway 192.168.0.1
  address 192.168.0.10
  netmask 255.255.0.0
  broadcast 192.168.0.255
  network 192.168.0.0
  bridge_ports wlan0 eth0
  pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

The wireless connection works fine when used alone, and the routing looks like:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     1000   0        0 wlan0
default         localhost       0.0.0.0         UG    0      0        0 wlan0

When I bring up br0 the routing table is identical with the exception that the Iface for each entry is br0, and it takes a significant amount of time to return the 'default' entry.

The other difference I noticed was when I list the interfaces using ifconfig, wlan0 no longer shows an IP address after bringing up br0.

The error returned when trying to ping either the router (192.168.0.1) or a public internet address is:
'Destination Host Unreachable' from br0's IP: 192.168.0.10.

Any ideas?

Thanks,
Jivan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伊面 2024-08-09 16:49:19

删除 eth0wlan0 的所有配置,只保留一个 br0 条目:

iface br0 inet dhcp
  bridge_ports wlan0 eth0
  pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

启动 br0 应该使用 wlan0 和 eth0 做正确的事情(它们没有自己的 IP 地址 - 相反,br0 现在是您的盒子连接桥接网络的接口。

Get rid of all the config for eth0 and wlan0, and just have a br0 entry:

iface br0 inet dhcp
  bridge_ports wlan0 eth0
  pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

Bringing up br0 should do the right thing with wlan0 and eth0 (they don't have their own IP addresses - instead br0 is now your box's interface to the bridged network.

栖竹 2024-08-09 16:49:19

首先,您必须删除用于桥的每个网络端口的网络配置,因为桥实用程序使用脚本自行配置它们。

您的配置应该看起来更像

auto wlan0
pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

auto br0
iface br0 inet static
 gateway 192.168.0.1
 address 192.168.0.10
 netmask 255.255.0.0
 broadcast 192.168.0.255
 bridge_ports wlan0 eth0
 pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed
iface br0 inet static
 address 192.168.0.15
 netmask 255.255.255.0
 broadcast 192.168.0.255

(如果您自己设置“广播”,则不需要条目“网络”)
(可以为一张网卡分配多个IP地址)

at first you have to remove your network configurations for every network port used for your bridge, because the bridge-utils using scripts to configure them on it's own.

your config should look more like

auto wlan0
pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed

auto br0
iface br0 inet static
 gateway 192.168.0.1
 address 192.168.0.10
 netmask 255.255.0.0
 broadcast 192.168.0.255
 bridge_ports wlan0 eth0
 pre-up iwconfig wlan0 channel 4 key <my-key> essid <my-essid> mode Managed
iface br0 inet static
 address 192.168.0.15
 netmask 255.255.255.0
 broadcast 192.168.0.255

(You don't need the entry "network" if you set "broadcast" on it's own)
(You can assign multiple ip addresses for one network card)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文