I'm trying to understand network bridging (not hardware but software implementation), but get some misunderstanding.

A network bridge connects two parts of a network together. For example my computer is connected to a local network throught eht0 and to the Internet throught wlan0. To share the internet connection in the local network I need to connect wlan0 and eth0 by network bridge. But why my routing table is not giving the same result without network bridge? I have the internet access, hence the routing table contains entries, that all outward packets should be passed through wlan0, hence packets that come from local network as well as generated by me should be passed through wlan0.

  • Where is my mistake?
  • How does network bridge fits in routing table ideology?

When you bridge two interfaces, they become bonded; anything coming in one and destined for a host on the other is automatically forwarded with no modifications. This allows packets to pass freely. Switches function as a bridge between all the ports on the switch.

You can still achieve the same effect by routing and forwarding the packets as well. This allows for much more control, as the packets are inspected and filtered, but this comes at the cost of increased processing time. To actually enable routing of incoming packets, you have to enable forwarding in the kernel and add the appropriate firewall rules. The kernel will then attempt to re-route any incoming packets that are not destined for the system itself. This also allows the system to perform network address translation (NAT) if necessary.

So, your mistake is not in the logic, simply that you've not configured your system to re-route/forward incoming packets.

Bridges don't really fit into a routing table ideology, because there is no routing involved with them. A computer on wlan0 will be able to see and talk directly to any computer on eth0. This is different from routing, where while computers on wlan0 can talk to computers on eth0 and vice-versa, they do not do so directly. Instead, the computers talk to the router, and trust the router will send it on to the appropriate destination.

  • @YLearn Thanks for pointing this out; I've tried to update the post to make it a bit more correct; Please edit it further if you feel it is warranted. – Darth Android May 7 '15 at 15:36
  • Much better. However, I would still adjust the statement "automatically forwarded with no modifications" as this is still incorrect, especially in the context of the original question. A frame that is received on eth0 is an 802.3 (Ethernet) frame, but the bridge will modify this so that it is sent out the wlan0 interface as an 802.11 frame and vice versa. While similar, they are two entirely different frame formats. – YLearn May 7 '15 at 17:30

Bridging links two parts of a single LAN, each part uses the same IP network address (i.e they are the same IP subnet). If other computers on the eth0 LAN and other computers on the WLAN0 network use the same network address and subnet mask then you do inded need to bridge the two segments. Some desktop operating systems can do this but they need to be configured to forward packets across LAN segments. Bridging is a layer-2 function (it works on MAC addresses)

This is not the same as routing, in routing the computers on the ETH0 LAN would have a different network address (be on a different IP subnet) to the computers on the WLAN0 segment. In that case the couputer would have to perform routing not bridging. Routing is a layer-3 function (it works on layer-3 addressing such as IP-addresses)

Routing tables only apply to routing, not bridging.

See Wikipedia for detailed descriptions.

  • Not true on Windows: routing affects the traffic on the bridge. For example when a vpn is created on the machine it basically adds a catch-all route and then packets comming into the bridge from external hosts are then routed accordingly! – Eric Jun 8 '18 at 17:41

Often in the context of software "network bridging" you must explicitly allow traffic to pass.

The network bridge is often an additional interface that must be turned on.

# ifconfig bridge0 addm fxp0 addm fxp1 up
# ifconfig fxp0 up
# ifconfig fxp1 up

Notice in the above sample fxp0 and fxp1 are connected using the bridge0 interface.

See more : Network Bridge In FreeBSD


Bridge will link the two networks as you said, for example if you configure bridge as your PC, then it will transfer the wlan0 to eth0 as what you desired but your PC wont able to access the internet as it is configured as a bridge and it wont get any IP as bridge is working on layer 2 (exactly like switch). If you really want route wlan0 to eth0 instead of bridging, then you can follow this three steps, it's like a router and working on Layer 3, steps:

  1. enable the kernel IP forwarding
  2. masqing with Pre-routing or post-routing (it actually passes the eth0 request to wlan0)
  3. Add the proper routing table( rules to access the gateway and also exactly like a firewall, you can restrict users to access the internet)

That's it. Now any of the eth0 clients can get access internet. Also the configured PC also can connect internet.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.