cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1375
Views
5
Helpful
8
Replies

Default Gateway

gurkamal01
Level 1
Level 1

Hi

Q1Can anybody please explain me what is the use of  ip dafault gateway on an L2 switch

I believe it is used when switch recieves an packet and its does where to forward the packet is this correct?

Q2. How does it work when a L 2 switch recieves an IP packet from the a server attached to for specified destination.

For eg a ping  request from Server A to --------------- Server B

Does the switch send an Arp request to find MAC-add of destination server if there no entry in the CAM table?

Q3 Can anybody please explain me how a L2 and L3 works

1 Accepted Solution

Accepted Solutions

Jon Marshall
Hall of Fame
Hall of Fame

gurkamal01 wrote:

Hi

Q1Can anybody please explain me what is the use of  ip dafault gateway on an L2 switch

I believe it is used when switch recieves an packet and its does where to forward the packet is this correct?

Q2. How does it work when a L 2 switch recieves an IP packet from the a server attached to for specified destination.

For eg a ping  request from Server A to --------------- Server B

Does the switch send an Arp request to find MAC-add of destination server if there no entry in the CAM table?

Q3 Can anybody please explain me how a L2 and L3 works

Q1 - as the others have said the ip default-gateway on a switch is used simply so you can connect to the switch itself from a remote subnet. It is not used to forward packets from devices attached to the switch. A L2 switch does not use the destination IP address to forward traffic, it uses the mac-address of the packet.

So when a L2 switch receives a packet it simply looks at the destination mac-address in the packet header and forwards the packet based on this ie. no L3 IP address lookup is done by a L2 switch.

Q2 - I'm assuming that Server A and Server B are in the same vlan because if they are not then you need a router or L3 switch somewhere.

L2 switches do not arp out for destinations when forwarding packets from hosts/servers etc. They simply look at the destination mac-address in the packet and forward the frame based on that mac-address. The arp request would have been made by Server A to get Server B's mac-address. And the response would have gone from B to A. The switch has a passive role in this ie. it doesn't initiate anything but it does "see"  the request and the answer so it can record which mac-addresses are found on which ports ie. serverA sends the arp request and the src mac-address would be serverA so the switch records serverA's mac-address on the port serverA is attached to. And when B replies it does the same for B.

If there is not entry in the CAM table for the destination mac-address then the switch simply sends the packet out of all ports in that vlan except the port it was received on.

Key thing to understand is that the switch is not doing any path/route lookups to forward the packets.

The above explains how a switch forwards packets from hosts attached to it. However a L2 switch also has a default-gateway. This is used differently. When the switch itself wants to communicate with a host or vice versa then it will have to arp out for a destination, either the host if it is on the same vlan as the switch or the default-gateway if the host is on another subnet. But this will only happen for communication to and from the L2 switch which is different from communication through the switch between 2 hosts.

Q3 - As Edison says, big question so this is not going to be a complete answer.

Fundamentally on ethernet L2 works with mac-addresses as explained above and L3 works with IP addresses.

L3 is concerned with getting the packet to the correct subnet. L2 is concerned with delivering the packet to the correct host once it is on the correct subnet.

We have covered a L2 switch and how it works above. Compare this with how a L3 switch works. For example you have 2 vlans on a L3 switch - vlan 10 & 11. A host in vlan 10 (H1)  wants to talk to a host in vlan 11 (H2) . So using the above definition the packet must first get to the correct subnet ie. it needs to be routed. H1 will need to send it's packet to the default-gateway for vlan 10 which should be the L3 SVI ip address for vlan 10 on the L3 switch.

And this is a key point too because you need to distinguish between an SVI on a L3 switch and an SVI on a L2 switch. On a L2 switch as mentioned the SVI is used merely for communication to and from the switch itself. On a L3 switch an SVI is used to send packets from a host on one subnet to a host on another subnet.

So from a mac-address/IP address perspective the packet looks like this -

H1 wants to talk to H. So H1 sends a packet to it's default-gateway (we'll assume all the necessary arp has been done)

src mac-address = H1

src IP address = H1

dst mac-address = L3 SVI for vlan 10

dst IP address = H2

the L3 switch then forwards the packet to H2

src mac-address = L3 SVI for vlan 11

dst mac-address = H2

src IP address = H1

dst IP address = H2

Notice in the above how the src/dst mac-addresses change at each L3 hop but the src/dst IP addresses are always the same ie. the 2 endpoints. This fits with what we said above ie.

L2 deals with getting the packet to the right endpoint on a subnet so for each subnet/L3 hop the mac-addresses will need to change.

L3 deals with getting the packet to the right subnet so the src/dst IPs will always stay the same

Jon

View solution in original post

8 Replies 8

glen.grant
VIP Alumni
VIP Alumni

   The default gateway has nothing to do with any attached device on a layer 2 switch. It is there to be able to manage that switch remotely and thats its only function .  Any device that needs to be routed talks to  a router or a L2/3  switch which does the routing for the subnet not the layer 2 switch itself.

Edison Ortiz
Hall of Fame
Hall of Fame

Q1Can anybody please explain me what is the use of  ip dafault gateway on an L2 switch         

To manage the switch from a remote subnet.

Without a default gateway, the switch won't be reachable from a subnet other than its own.

Q2. How does it work when a L 2 switch recieves an IP packet from the a server attached to for specified destination.

The switch does not route. It only captures the MAC addresses from the attached devices.

For eg a ping  request from Server A to --------------- Server B

Does the switch send an Arp request to find MAC-add of destination server if there no entry in the CAM table?

If both servers are on the same subnet and they are assigned to the same Vlan on the switch, the switch will simply switch the packet from the ingress port on Server A to the egress port on Server B and viceversa. Not routing is involved, pure L2 connection.

Q3 Can anybody please explain me how a L2 and L3 works

That's a loaded question, can be a bit more specific?

Thanks for the reply Edison

As for the first question

I have L2 switch in my network which doenot have an default gateway and i can still reach it form  different subnet.

how is does that work

For Q2.

what if the both server are on a different subnet. how willl that work

Thanks

I have L2 switch in my network which doenot have an default gateway and i can still reach it form  different subnet.

A L3 device on that segment is doing Proxy-ARP

what if the both server are on a different subnet. how willl that work

You will need a router as the L2 switch will simply drop the packet if the destination is not on the same Vlan.

Edison

Thanks for the reply

You will need a router as the L2 switch will simply drop the packet if the destination is not on the same Vlan

Q1 So i need to attach router to the L2 switch in order for route between 2 servers

is this correct

Yes, that's correct

And the servers will need to have a default gateway pointing to the correct exit point from that subnet.

gurkamal01
Level 1
Level 1

Jon,

Can i get an output from you on these 3 questions in this post

i will really appreciate that

Jon Marshall
Hall of Fame
Hall of Fame

gurkamal01 wrote:

Hi

Q1Can anybody please explain me what is the use of  ip dafault gateway on an L2 switch

I believe it is used when switch recieves an packet and its does where to forward the packet is this correct?

Q2. How does it work when a L 2 switch recieves an IP packet from the a server attached to for specified destination.

For eg a ping  request from Server A to --------------- Server B

Does the switch send an Arp request to find MAC-add of destination server if there no entry in the CAM table?

Q3 Can anybody please explain me how a L2 and L3 works

Q1 - as the others have said the ip default-gateway on a switch is used simply so you can connect to the switch itself from a remote subnet. It is not used to forward packets from devices attached to the switch. A L2 switch does not use the destination IP address to forward traffic, it uses the mac-address of the packet.

So when a L2 switch receives a packet it simply looks at the destination mac-address in the packet header and forwards the packet based on this ie. no L3 IP address lookup is done by a L2 switch.

Q2 - I'm assuming that Server A and Server B are in the same vlan because if they are not then you need a router or L3 switch somewhere.

L2 switches do not arp out for destinations when forwarding packets from hosts/servers etc. They simply look at the destination mac-address in the packet and forward the frame based on that mac-address. The arp request would have been made by Server A to get Server B's mac-address. And the response would have gone from B to A. The switch has a passive role in this ie. it doesn't initiate anything but it does "see"  the request and the answer so it can record which mac-addresses are found on which ports ie. serverA sends the arp request and the src mac-address would be serverA so the switch records serverA's mac-address on the port serverA is attached to. And when B replies it does the same for B.

If there is not entry in the CAM table for the destination mac-address then the switch simply sends the packet out of all ports in that vlan except the port it was received on.

Key thing to understand is that the switch is not doing any path/route lookups to forward the packets.

The above explains how a switch forwards packets from hosts attached to it. However a L2 switch also has a default-gateway. This is used differently. When the switch itself wants to communicate with a host or vice versa then it will have to arp out for a destination, either the host if it is on the same vlan as the switch or the default-gateway if the host is on another subnet. But this will only happen for communication to and from the L2 switch which is different from communication through the switch between 2 hosts.

Q3 - As Edison says, big question so this is not going to be a complete answer.

Fundamentally on ethernet L2 works with mac-addresses as explained above and L3 works with IP addresses.

L3 is concerned with getting the packet to the correct subnet. L2 is concerned with delivering the packet to the correct host once it is on the correct subnet.

We have covered a L2 switch and how it works above. Compare this with how a L3 switch works. For example you have 2 vlans on a L3 switch - vlan 10 & 11. A host in vlan 10 (H1)  wants to talk to a host in vlan 11 (H2) . So using the above definition the packet must first get to the correct subnet ie. it needs to be routed. H1 will need to send it's packet to the default-gateway for vlan 10 which should be the L3 SVI ip address for vlan 10 on the L3 switch.

And this is a key point too because you need to distinguish between an SVI on a L3 switch and an SVI on a L2 switch. On a L2 switch as mentioned the SVI is used merely for communication to and from the switch itself. On a L3 switch an SVI is used to send packets from a host on one subnet to a host on another subnet.

So from a mac-address/IP address perspective the packet looks like this -

H1 wants to talk to H. So H1 sends a packet to it's default-gateway (we'll assume all the necessary arp has been done)

src mac-address = H1

src IP address = H1

dst mac-address = L3 SVI for vlan 10

dst IP address = H2

the L3 switch then forwards the packet to H2

src mac-address = L3 SVI for vlan 11

dst mac-address = H2

src IP address = H1

dst IP address = H2

Notice in the above how the src/dst mac-addresses change at each L3 hop but the src/dst IP addresses are always the same ie. the 2 endpoints. This fits with what we said above ie.

L2 deals with getting the packet to the right endpoint on a subnet so for each subnet/L3 hop the mac-addresses will need to change.

L3 deals with getting the packet to the right subnet so the src/dst IPs will always stay the same

Jon

Review Cisco Networking products for a $25 gift card