Network Engineering Stack Exchange is a question and answer site for network engineers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is meaning of the ip default-gateway command on a Cisco L2 switch? I read something about it on the Internet, but there was written that it allows you to Telnet to the switch. I am little bit confused. When I want to Telnet to the switch, I set the IP address of the VLAN 1 interface, and it works.

share|improve this question
up vote 9 down vote accepted

tl;dr

The switch management cannot send anything to a different layer-3 network without a default gateway. Telnet is a bidirectional protocol, and the switch, without the default gateway, would be unable to respond to the host which is attempting to establish the Telnet session.

Long explanation:

The default gateway on a switch has the same function as any gateway configured on a host PC. Without a default gateway, the switch management address (on VLAN 1 in your case, but it could be on any VLAN configured on the switch) cannot send traffic off its network to another network.

When a host (including the switch management), wants to send a packet to another host, it needs to resolve the layer-3 address (IP, etc.) to the other host's layer-2 address (MAC, etc.) in order to build a layer-2 frame.

The host (including the switch management) sends an ARP (Address Resolution Protocol) request via a broadcast to do the resolution. Broadcasts do not cross layer-3 boundaries (routers). The host (including the switch management) can tell if the destination layer-3 address is outside its network because it has its own layer-3 address, the destination layer-3 address, and the network mask of its network. If the destination is on a different layer-3 network, the host (including the switch management) will send the frame to the gateway's layer-2 address.

IPv6 does basically the same thing, but IPv6 doesn't have broadcasts, so it uses a special multicast group based on the last 24 bits of the IPv6 address. This doesn't interrupt every host on the LAN, and it, in all probability, with only hit the host for which it wants to resolve the layer-2 address. Multicast doesn't cross layer-3 boundaries, either, unless a router is configured to route multicast (off by default).

share|improve this answer

The short answer here is that the default gateway is the local router that gets traffic to other networks. It is the default way to get off of your network.

Remember, routers connect networks and switches create networks. If you are off on another (non-Vlan1) network, you must route the traffic. For instance, your home LAN (x.x.x.x) and your ISP network (y.y.y.y) have a router to connect them (commonly called a cable modem).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.