It is my understanding that the main difference between a network hub and a network switch is that the hub always sends out all packets to all (other?) hosts while the switch is smart about it and keeps track of which port belongs to which MAC address via MAC address tables and whatnot. If a packet is addressed to a host which is connected to the switch but have never sent or received anything, the switch acts like a hub would. But every subsequent packet addressed to that host is not broadcast to the other hosts but forwarded only to that specific host. Please correct me if I got something wrong.

Does a network bridge in Linux act like a hub would, or like a switch?

  • A bridge is a special case of a switch in the network theory, no matter what tech you are using. This does not seems a Unix doubt. – Rui F Ribeiro Mar 15 '18 at 14:12
  • The reason I posted it here was because I suspect that a bridge net device might be implemented differently on different platforms/paradigms. – lindhe Mar 15 '18 at 14:16
  • hub does indeed send out all received packets to all of its other ports. switch is indeed smart, compared to a hub, and only sends packets out on the port that has the intended recipient. fancy term to search for is collision domains. generally, hubs have them, switches do not. how a cots switch actually does its cleverness i would not know. i suspect linux net bridge can be made to do either. it can certainly do a hub as i have done this – northern-bradley May 31 '20 at 13:14
  • 2
    Mostly correct: except it is not an arp table. arp is to convert IP address to mac address. The switch knows nothing of IP. It is just mac-address table. The bit about subsequent packets. The mac-address table can only be populated by received packets from a mac-address. If a node is sending to an unresponsive node then its mac-address can never be put in the table, as there is no way to know its location. – ctrl-alt-delor May 5 at 17:00
  • Certainly true, thanks for the correction! – lindhe May 6 at 15:21

A bridge is a network aggregation device, similar in practice to a switch. The bridges implemented in the Linux kernel follow this model. Like any bridge, they forward traffic based on destination MAC addresses, once the MAC address mapping is known. They are actually more featureful than most switches, since they also support firewalling, traffic shaping etc., using ebtables.

See the bridge documentation for details.

  • 2
    (I implemented bridges in DOS and Cisco in the 90s supporting port-based firewalling ;) in Linux too later on, but honestly cant remember for what. Protecting the gateway of a wifi network? Cant remember. I also have a Linux bridge at home because of Apple multicast protocols ) – Rui F Ribeiro Mar 15 '18 at 14:17

actually there is a small difference between the switch and hub.hub don't store the mac of connected devices,so the packets received from any host reaches every other connected hosts .Where as switch stores the mac of connected devices and send the packet to respective receiver whose details(like mac,ip) mentioned in packet headers....

  • 2
    I don't think I understand what you mean I got wrong. To me, it seems like I described it similar to what you say. Also, I think this is not an anser to my question, but rather a comment (which I appreciate, btw). Also also, when talking about switches, it's usually implied that it is L2 switches, and they do not care about any packet header, only the frame header (so no IP). – lindhe Mar 15 '18 at 20:00

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.