Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have some very trivial basic questions about networking, but I find varying information on that, so I just wanted to settle this.

As far as I understand a Network Switch handles traffic "intelligently" in the way that it only propagates packets to its port where it knows that the receiver is located (In contrast to Hub which brute force sends all data to all ports).

  • Correct?

So a Switch needs to remember all adresses of Hosts connected to it. If the host is not found the packet is sent to the default route (commonly Up link to a wider network)

  • Correct?

Now my major question is:

  • Does a Switch remember IP-Addresses or MAC-Addresses to calculate its decisions?
share|improve this question
add comment

4 Answers

up vote 18 down vote accepted

Well, this depends on what kind of switch you are using.

The very basic types operate at the link layer and are not aware of IP addresses. They use MAC addresses for their operation. These switches are often unmanaged.

However, there are also more intelligent switches, which offer functionality at the IP layer, such as access control lists, and these are aware of IP addresses. In general, these switches are managed, i.e. they have either a web interface or a console interface (or both) to allow the user to configure the various options. However, the additional functionality works on top of the basic switch functions.

Switches "learn" the MAC addresses of devices connected to their ports by listening to the traffic, and use them to decide where to send incoming datagrams. Switches in general do not perform routing. This is usually done by routers, and the datagrams sent by the router use the link layer address (MAC address in ethernet networks) to send the packet to the next hop.

share|improve this answer
6  
VLANs are not IP layer; they operate at Layer 2. With most Layer 2+3 switches, however, you can assign an IP address to a VLAN interface. Perhaps that's what you meant. –  gravyface May 21 '11 at 13:04
    
@gravyface - I went ahead and corrected that. It's a good answer otherwise, so +1. –  EEAA May 21 '11 at 14:01
    
You can only assign an ip to à non-management vlan on L3 switches. –  3molo May 21 '11 at 14:47
1  
The most common feature -- and the real reason people use them -- is for routing between VLANs, however. This prevents the need to go all the way to the router for intranet communication. The router is busy handling WAN traffic and could be a bottleneck given a large enough network and a router-on-a-stick configuration. It's common for distribution and core layer switches to handle this routing instead of the router. –  Bacon Bits May 21 '11 at 20:40
add comment

As far as I understand a Network Switch handles traffic "intelligently" in the way that it only propagates packets to its port where it knows that the receiver is located (In contrast to Hub which brute force sends all data to all ports).

Yes, that is correct.

So a Switch needs to remember all adresses of Hosts connected to it. If the host is not found the packet is sent to the default route (commonly Up link to a wider network)

Well, not quite. It's true that a switch remembers which hosts are connected to which port (usually by observing the MAC addresses of the packets arriving on the ports). However a switch normally does not know about the "default route", as that is a concept from a higher networking layer. Switches work on layer 2 of the OSI model (data linke layer). The "default route" is a concept used for routing, which happens at layer 3 (network layer).

A switch therefore does not have a "default route". If it does not know a destination MAC address, it just sends the packet to all ports (at least at the beginning, that's all it can do - this is known as "flooding"). At any rate, in an ethernet, each packet must be addressed to a local MAC address, otherwise it'll never arrive. Packets sent "out to the internet" still get a local MAC address destination, namely the address of the network's default gateway. The switch just passes this packet on to the default gateway, and the gateway (which operates at layer 3) then reads the "real" destination from the IP address embedded in the packet and sends it on its way.

Does a Switch remember IP-Addresses or MAC-Addresses to calculate its decisions?

As explained above, a switch is IP-agnostic, as it works on a lower level of abstraction. Thus, only MAC-addresses.

One complication: As explained in wolfgangsz's answer, there are switches which also operate on layer 3 (so-called multilayer switches). These are a bit more complicated, and they can handle IP addresses and more.

share|improve this answer
add comment

Check out the wikipedia entry on Network Switch, particularly the "layer" information.

The "layer" is (roughly) the OSI layer at which the switch operates.

share|improve this answer
    
@downvoter: Why? –  Peter K. May 23 '11 at 23:29
add comment

Just to add slightly to the answers from @wolfgangsz and @sleske, it should be emphasised that a standard switch is, as already stated, purely a layer 2 device therefore it only understands MAC addresses.

Although a 'packet' is often used as a generic term, the protocol data unit (PDU) at layer 2 is a 'frame', at layer 3 the PDU is a packet.

A 'multi-layer switch' can be thought of as a switch that contains a router which, unlike traditional routers, routes packets from VLAN to VLAN instead of from one physical interface to another physical interface.

If a switch supports VLANs (this does not necessarily make it a multi-layer switch) then a frame with an unknown destination MAC address will be sent out of all the ports (known as flooding) that are members of the same VLAN as the packet was received on because a VLAN is a broadcast domain and frames do not go beyond the border of broadcast domains.

EDIT: For completeness I should also mention that switches that support VLANs will also support trunk ports, these use extended frames that allow traffic from multiple VLANs to be carried on a single physical link.

share|improve this answer
    
There's some good info here. Seems like it could be contextualized more and mereged with wolfgangsz to add an explanation of layer 2/3 switches. –  JamesBarnett May 23 '11 at 9:30
    
If I had the faintest idea how to do that I would be quite happy to, I was an advanced level Cisco trainer in a previous life so can expand as much as is required. –  blankabout May 23 '11 at 14:51
    
Should have put in @JamesBarnett in my previous comment –  blankabout May 23 '11 at 19:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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