Solved

Simple question - switches & default gateways

Posted on 2004-08-21
5
401 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

785 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