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?
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.
Yes, that is correct.
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.
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.
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.
Check out the wikipedia entry on Network Switch, particularly the "layer" information.
The "layer" is (roughly) the OSI layer at which the switch operates.