Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

Simple question - switches & default gateways

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
alsace
Asked:
alsace
  • 3
  • 2
1 Solution
 
scampgbCommented:
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
 
alsaceAuthor Commented:
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
 
scampgbCommented:
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
 
alsaceAuthor Commented:
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
 
scampgbCommented:
Hi Alsace.  Thanks for the "A".  Glad I could help.

Your summary is absolutely perfect :-)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now