LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 August 21 2007

Locha
Member

Router or Switch ? What's the difference ?

Hey mates,

i have my hub who is not working and i thought of changing it . When i went to get one, i saw a Switch with 8 Ports & a router with 4 Ports which looked the same as appearances except the number of ports.

i have at home 2 computers with 2 IPs ... What should i get in order to get the connection ?

Thank you.

Regards

Offline

#2 August 21 2007

7aRami
Member

Re: Router or Switch ? What's the difference ?

difference is simple, a router is used to connect computer on different subnets, or let's say it can connect different subnets together.
a subnet is a collection of IPs that can "see" each others without the need of a router in between. for example network 192.168.1.0 with mask 255.255.255.0 can have 254 computers connected using hubs/switches with no need for a router, since they will all be on the same subnet or range.
but if you have a computer on 192.168.1.X and another computer on 192.168.2.X you will need a router between them.

hub and switches don't do routing, they will pass data packets to destination computers, they are similar but each operates in a different way.

at home I have the same setup as yours, I bought a small router, I let it connect to the internet, and then I let my 3 computers connect to that router. at the end, the router will be acting as their gateway to the internet.

Offline

#3 August 21 2007

mir
Member

Re: Router or Switch ? What's the difference ?

7arami.. daya3to lal sabeh aw lal bint

difference between router and switch ano router is a smarter device than a switch
ismo router cuz it can take decisions it can decide on what routes to take
fi advanced routers ha2on shi malyoun dollar... aktar shi famous Cisco routers

but like one of the guys here said they are just GPLed products with cheap equipement that just look scary

hala2 the switch don't take decisions .. they just send the data

if there is no big  difference in price range get the router

if you have any laptop or plan to get one , it is nice if u get something wireless like that it will be cool when ur friends come to ur place and u wirelessly connect their laptop w btisrdouwa w betjagel 3layon
and it will give u mobility

Last edited by mir (August 21 2007)

Offline

#4 August 21 2007

Locha
Member

Re: Router or Switch ? What's the difference ?

sabeh sabeh mir :) ...

The idea that i want to deliver that am already taking 2 IPs from the provider ... Am not in need to divide the connection in order to connect many pcs ... So in that case, the switch & the router can take this role ?

Wel Tejgil Ma Bye3nina ...

Regards

Offline

#5 August 21 2007

rolf
Member

Re: Router or Switch ? What's the difference ?

a switch will replace a hub very well. Get a switch.
But if you get a router and set it up with NAT and port forwarding you will have higher security. But it is complicated to set up. It may be easyer to leave your setup as it is and just get a switch and make sure your 2 PCs are up to date and have antiviruses and firewalls.

Offline

#6 August 21 2007

WizaRd
Member

Re: Router or Switch ? What's the difference ?

But what about his 2 different IPs? How would he be able to get them through the router on 2 different "connections" ?

Offline

#7 August 21 2007

rolf
Member

Re: Router or Switch ? What's the difference ?

true, he needs to use one connection only if he has a router.

Offline

#8 August 21 2007

battikh
Member

Re: Router or Switch ? What's the difference ?

1st don't listen to mir, she's on the software side, she's trying to sabotage the networking side. and don't believe her when she says that switches don't take decisions, coz they do.

anyways, if you were using a hub, as rolf said, a switch is more than enough, no need to "invest" in a router.

Offline

#9 August 21 2007

Locha
Member

Re: Router or Switch ? What's the difference ?

Thank a lot guys ... i really appreciate it

Regards

Offline

#10 August 22 2007

mir
Member

Re: Router or Switch ? What's the difference ?

1st don't listen to mir, she's on the software side, she's trying to sabotage the networking side. and don't believe her when she says that switches don't take decisions, coz they do.

Lah ya 3ammeh , ma 3am kazeb on purpose 3al sabeh
sorry khayeh battikh .. bas mitel ma khabarna istez l networking (he is a really good teacher ) routers have routing tables
i never heard of a switching table

is it new kind of switches ?
plz do explain more
if u can give examples would be great
i will go digging in my courses

Offline

#11 August 22 2007

battikh
Member

Re: Router or Switch ? What's the difference ?

in fact switches do have switching tables. it's a table containing all the mac addresses discovered by the switch and on which port he discovered them. the switch builds it himself so he can know that a specific mac address can be contacted on a specific port. so if some data is meant to be sent to a certain mac address the switch knows on witch port to send it and sends it ONLY to this port besides sending it to all ports (which would made him act as a hub)

Offline

#12 August 24 2007

mir
Member

Re: Router or Switch ? What's the difference ?

those are the level 3 switches
i didn't take them into consideration
thanks for the infos battikh

Offline

#13 August 24 2007

battikh
Member

Re: Router or Switch ? What's the difference ?

those are layer 2 swicthes.
layer 2 switches have a cam table to have the mac address/switchport correspondance and to be able to do switching. it's thanks to the cam table that the switch can know on which port a machine is and which makes it able not to act as a hub.
layer 3 switches are switches who have routing capabilities and have a cam table AND a routing table.

a little example....
we have computer A, computer B and computer C interconnected threw a switch
computer A --> MAC A
computer B --> MAC B
computer C --> MAC C

                   +---------+
  comp A-----|  switch  |------comp B
                   +---------+
                          |
                       comp C

comp A is connected on switchport 1
comp B is connected on switchport 2
comp C is connected on switchport 2

now let say the switch has just been booted and the cam table is empty, so the switch has no idea what are the MACs available in the network and where they are.
now comp A send a frame to comp B (source MAC=MAC A, destination MAC=MAC B). the frame reaches the switch via switchport 1 (as comp A is connected to switchport1). the switch, being smart and fully layer 2 (not layer 3), will start reading the header of the frame (he can read more, but we'll consider he is working in fast forward, even though he could read the whole frame and check the CRC checksum and determine that there is an error in the frame, which would make it even smarter). ok, so the switch read the layer 2 header of the frame he received on switchport1. so he can now deduce that the source of this frame can be reached via switchport 1 (as the sender sent it from there). so now the switch knows that MAC A is on switchport 1. he will add this info in his cam table.
cam table become:
MAC | switchport
  A    |    1

ok, now the switch has to send the frame to the destination. destination is MAC B. on which switchport will it forward it? it will check in it's cam table... it will search for MAC B....mmmm, nothing, concerning MAC B in the cam table...what to do? it will forward it on all switchport besides the one it came from, so basically it will act as a hub. so now the frame will be sent on switchport 2 and 3 and computer B will receive it.

ok, now lets say computer B will answer computer A. Comp B send a frame, it reaches switchport 2. now the switch knows that B is on switchport 2, it will added it to the cam table:
MAC | switchport
A    |      1
B    |      2

now it has to forward the frame to MAC A. it will check its cam table, will see that MAC A is reachable via switchport 1 and will forward the frame ONLY to switchport 1 (not acting as a hub anymore).

and voila, that's basically how a layer 2 switch makes some decisions....
and yeah, comp C was useless in my example, so what?

Offline

#14 August 24 2007

battikh
Member

Re: Router or Switch ? What's the difference ?

wtf, i wrote all that?
i must be very bored!!!!

Offline

#15 August 27 2007

mir
Member

Re: Router or Switch ? What's the difference ?

wtf.. layer 2 switches work like this ..
i wanna kill my networking teacher
ano.. w iza ne7na programing ? shu bi3almouna galat

i got the idea of how dynamically the switch fills its cam table

NO.. Comp C is not useless.. he could be sniffing traffic

thank you battikh for the explanation
but couple of other questions :

can u manually program that  cam table also ?
can u program the layer 2 switches to add security for example C can not send to A w heik ossas ?

Last edited by mir (August 27 2007)

Offline

#16 August 27 2007

battikh
Member

Re: Router or Switch ? What's the difference ?

it's mainly depending on the switch, these are extra features. as my teacher always said, switches do switching, everything else is extra features.
in cisco router you have some security options (port security), you can for example disallow more than x number of macs on the same port (you block someone from putting a hub/switch on a port of the switch), or you can allow only a certain mac address on a certain port.
to disallow comp a to talk with comp c i think u have to go for a layer 3 switch and add an access-list.
to add entries to the cam table manually, well even if it is not a feature of the switch you can do it, all you have to do is spoof your mac and send something (or just generate a packet with a source mac being the mac you want to add) and send it on a specific port, the switch will think that a comp with this mac is reachable via this port. but dynamic entries in the cam table have a time to live, they get removed after a certain time if nothing was heard from this mac for x seconds.


for the example and comp c
while sniffing he will only get the 1st packet that was sent, all the other wont reach his port. to be able to sniff he'll need to activate port mirroring on the switch (if the option is available) or attack the switch like by flooding it with packets with a random mac address, the cam will get filled (it has a limited memory space) so some switches would start acting like a hub in such a situation.

and what did ur teacher tell you about layer 2 switches?

Offline

#17 August 27 2007

nuclearcat
Member

Re: Router or Switch ? What's the difference ?

Actually most of cheap switches contain powerful chips. A little bit soldering - and u can have semi-managed switch.
Stupid cheapest D-Link for example, can support VLAN's (including port-based and 802.1q), depends on revision - mac-lock like on cisco, and many other stuff. By adding $4 controller, and few more parts (for $5-$6) , we can do 8-port powerful manageable switch costing around $50 max :-)

Offline

#18 February 4 2008

rebel0
Member

Re: Router or Switch ? What's the difference ?

Man, instead of getting two ips you can get one higher bandwidth ip and work on it through the router , ya3neh if you have two ips 128 kb/s each, just get one 256 kb/s ip and configure it on the router, and use the NAT feature on the router and you can have all the connection to any computer connected to the router, its much cheaper,ya3neh fik testa3mil one ip for many computer using the router so why have 2.

Offline

Board footer