Solved

Simple question - switches & default gateways

Posted on 2004-08-21
5
402 Views
Last Modified: 2010-04-11
This should be a simple one guys...but I seem to be getting myself confused.

What is the purpose of setting a Layer 3 gateway address on a Layer 2 switch (using the ip default-gateway command)?

Scenario: A PC connected to a L2 switch (eg 1900, 2950) sends a frame to a PC on another subnet. Lets assume there is full connectivity between the 2 devices (pings OK). I know that the local routing table is checked (on the PC), nothing found locally so the frame is sent to the PC's default gateway (which would be the router). All cool...except here is where I am over-complicating things I think:

Before the packet even gets to the router it must go through the switch - when the frame gets to the switch port, I thought the switch would check its CAM table (this is the MAC addresstable yes?) for the routers MAC address and forward the frame out the correct port (assuming the router was directly connected OR the routers MAC address was learnt via a routing protocol).

1. Is this procedure correct? If so, when does the default gateway of the switch come into play?

2. When setting the switch's default gateway address, would it have to be the same as the PCs?

Thanks,

Alsace.
0
Comment
Question by:alsace
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:scampgb
ID: 11858947
Hi alsace,

Your understanding is pretty accurate, but I can see where you become confused.

In this environment, the switch doesn't do any routing at all - it just plays nicely at level 2 and shuffles packets between its interfaces based on MAC address.
To this extent, your understanding is correct.

However, the router in question also has an IP address.  It has an IP address so that you can configure, manage and monitor it.
All that's well and good if the PC you're using to configure it is on the same IP subnet as the switch.  However, that would not always be the case, in which case the switch has a default gateway.

Essentially, the switch doesn't use it's IP address or default gateway for the purposes of being a switch (layer 2).  However, it does need them for you to manage the switch.

Does that make sense?
0
 

Author Comment

by:alsace
ID: 11859277
I think so scampgb... thanks for the reply... you have cleared up the IP address query.("However, the router in question also has an IP address.  It has an IP address so that you can configure, manage and monitor it."). Did you mean to say the 'switch' in question?

If so, I understand that it has a layer 3 address for management reasons, but still struggling to see how a switch can use a default gateway, unless it was for unresolved addresses that the switch ITSELF was trying to resolve... is that right?

This is from the Cisco website (how to configure the ip default-gateway address on a 2950): "Enter the IP address of the next-hop router interface that is directly connected to the switch where a default gateway is being configured. The default gateway receives IP packets with unresolved destination IP addresses from the switch. Once the default gateway is configured, the switch has connectivity to the remote networks with which a host needs to communicate. Note When your switch is configured to route with IP, it does not need to have a default gateway set."

So would it be fair to say that the switch would use it's default gateway if, for example, I telenetted into it (or used the console) and pinged another host on another IP subnet from that session? That is, I was using the switch for some layer 3 functions when I was managing the switch?

Thanks again,

Alsace.
0
 
LVL 15

Accepted Solution

by:
scampgb earned 125 total points
ID: 11859309
Hi Alsace - well spotted! I did indeed mean to type "switch"

OK, it's important to understand the differences between Layers 2 & 3.

A switch operates at layer 2.  It's job is to get ethernet frames from one place to another, and switches by MAC addresses.
If it doesn't know where a MAC address is, the IP default gateway doesn't come into it at all.
If it can't find it, then it broadcasts and layer 2 out of all of its ports, and hopes that it gets a response.

IP is a layer 3 protocol.  The switch understands it for the purposes of management.  As you rightly point out, many switches are more intelligent than that and will allow you to do pings and traceroutes.
If you've telnetted to the router, and asked it to ping something that is not on it's subnet, it will direct the IP packets to it's default gateway in the same way that any other device (PC, printer) would.

As for the stuff from Cisco's website, that further complicates matters :-)  
When it says "unresolved destination IP addresses", it really is talking about it's own layer 3 IP communication.  Unresolved in this case means it doens't know how to route to it.
It is possible to configure a switch (layer 2) to perform some of the functions of a router (layer 3).  This is a whole other area though!

Does that help?
0
 

Author Comment

by:alsace
ID: 11861536
Yep - perfectly.

To summarize I think I am getting the switches MANAGEMENT functions (layer 3) confused with it's SWITCHING functions (Layer 2).

Thanks again scampgb.

Alsace
0
 
LVL 15

Expert Comment

by:scampgb
ID: 11863247
Hi Alsace.  Thanks for the "A".  Glad I could help.

Your summary is absolutely perfect :-)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MSSQL server connection  forced closed 3 39
can't ssh to external IP 9 27
Price for Fiber 13 34
Alot of sessions on a PC is generated 3 21
For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question