Solved

Simple question - switches & default gateways

Posted on 2004-08-21
5
399 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi Alsace.  Thanks for the "A".  Glad I could help.

Your summary is absolutely perfect :-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now