LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2011, 05:23 PM   #1
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Rep: Reputation: 20
bridge or router?


Hello,

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)
 
Old 12-21-2011, 05:48 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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.
 
Old 12-22-2011, 03:54 AM   #3
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Original Poster
Rep: Reputation: 20
Can I have a bridge connecting two different subnets?
 
Old 12-22-2011, 12:47 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Yes; think of a bridge like a simple switch or hub.
 
Old 12-24-2011, 05:29 PM   #5
TimothyEBaldwin
Member
 
Registered: Mar 2009
Posts: 249

Rep: Reputation: 27
Quote:
Originally Posted by bujecas View Post
Can I have a bridge connecting two different subnets?
You can't, you need a router.
 
Old 12-24-2011, 08:59 PM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
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.

More info, plus pros and cons, enumerated here:
http://en.wikipedia.org/wiki/Bridging_%28networking%29
 
Old 01-09-2012, 03:28 PM   #7
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
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.

Last edited by baldy3105; 01-09-2012 at 03:29 PM.
 
Old 01-12-2012, 09:01 AM   #8
castorw
LQ Newbie
 
Registered: Jan 2012
Distribution: Debain, Gentoo
Posts: 9

Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Transparent router/bridge PlancksCnst Linux - Networking 4 07-28-2010 01:39 PM
Creating a bridge from ADSL router to WLAN router linuxlainen Linux - Networking 7 02-12-2009 11:20 AM
Connecting 2 machines using my DSL router (or router/bridge) resetreset Linux - Networking 3 07-29-2008 04:18 AM
AP, Bridge or Router? bigearsbilly Linux - Wireless Networking 10 02-15-2005 09:05 AM
Help, after setting up bridge I can only ping my router. Royle Linux - Networking 0 11-11-2004 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration