Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm a little confused about the bridge and router thing. I know that bridge works at layer 2, only understands MAC addresses and doesn't care about upper protocols (network layer 3). A router works at the IP level (layer 3) and can do forwarding of packets and filtering.
Here's the scenario:
Two different subnets:
NET_A: 192.168.1.0
NET_B: 192.168.2.0
Goal: host X on NET_A want's to communicate with host Y on NET_B and vice-verse
This should be done with a bridge or a router? (Considering that both bridge and router are Linux servers)
It depends on what you want. If you want to have all packets on NET_A visible to all hosts on NET_B (and vice versa) then you want a bridge. If you want NET_A traffic to stay on NET_A, and NET_B traffic to stay on NET_B, but forward packets from one net to the other addressed to specific hosts, then you want a router.
Yes, OP can connect two networks using either a (layer 2) bridge or a (layer 3) router. Unless the networks are quite small and/or low-traffic, a router probably makes more sense.
No. The basic rules of IP state that to communicate from a host in one IP subnet to a host in another IP subnet they must communicate via a gateway (same as router according to the IETF). You can most certainly bridge the two networks so that each host will receive each others layer2 frames but if you ask host A to send an IP packet to host B it will recognize that the destination is off network and will only send this packet over ethernet if it can find a next-hop via ARP, which requires that it has a route or default gateway configured.
I have assumed that your two hosts are using a standard /24 mask. if your mask is /16 then the two hosts are in the same subnet and can communicate directly via L2.
Simply, if u want your networks separated you will need some host to be router (pc, embedded system). This adds you possibility to control traffic passing between networks.
If you just want these hosts to communicate w/o any extra control, everything you need is unmanaged switch and throw all the hosts in one network. In your case at least /23 network, if you want 192.168.1.0 and 192.168.2.0 networks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.