cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
219013
Views
51
Helpful
19
Replies

Switch command ip default-gateway

wfqk
Level 5
Level 5

Hi I saw the following: 

 

" ------------------

Use the following commands to assign the IP address 192.168.1.254 to VLAN 1, which is the management VLAN by default:
TEswitch1(config)#interface vlan 1
TEswitch1(config-if)#ip address 192.168.0.9 255.255.255.0
TEswitch1(config-if)#no shutdown


If you need to be able to connect to the switch from other networks, you will also need to configure a default gateway address. For example, if the switch is connected to a router with the IP address 192.168.1.254, use the following command, in Global Configuration mode, to use it as the default gateway:
TEswitch1(config-if)#exit
TEswitch1(config)#ip default-gateway 192.168.0.254

------------------------ "

My question is why we still need to use command ip default-gateway since the router still can reach the switch from other network without the ip default-gateway. 

 

Thank you

19 Replies 19

Hello,

Reza has given you the answer, however for an analogy, consider the switch as youe laptop/PC. It needs a default gateway to talk to other subnets other than local lan. 

It is as simple as that.

 

Hope this helps.

Thanks,

Madhu.

 

 

Bilal Nawaz
VIP Alumni
VIP Alumni

It's debatable whether default-gateway command is needed on L2 switch. But it all depends on one thing. If the actual default gateway is enabled for proxy arp/auto arp response, then automatically the reachability to the switch from another subnet will indeed work - perhaps this is what's happening in your scenario. (without default-gateway command)

If proxy arp is disabled on the gateway, then you must have the default gateway command, like any other host that needs to reach another subnet, albeit sourced traffic or return traffic.

Please rate useful posts & remember to mark any solved questions as answered. Thank you.

Hello

My understanding =

A switch running as a layer 2 device ( no ip routing enabled) is basically a "host" just like a pc.

Now if you would like to access a network device to/from this switch remotely ( that is off a subnet other than vlan1 in your example) then a default-gateway would be required.

 

The reason being -

L2 switching deals with switching where the frame is sent to a DMAC ( destination mac address) in the same vlan  (again in your case vlan 1)

(host) 192.168.0.9 to (host) 192.168.0.10 (  L2 switching)

 

L3 switching/routing = Where the DMAC is not on the same Vlan as the SMAC  (source mac address) it needs to go to a device that has routing capabilities ( the address of the default-gateway)

A D/G is usually router or a switch with L3 processing capabilities which will perform route lookups and forward  packets towards the remote destination or towards another router/l3 switch which is closer to the destination 

As your switch will know the physical address of the D/G then routing ( inter vlan ) can occur and remote connectivity can be established to/from your switch just like a pc would do

 

(Host) 192.168.0.9 to 192.168.0.254 (D/G) to (host) 193.168.0.9 (  L3 switching)

 

res

Paul

 

 

 

 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Hi Paul, my understanding is different to yours. 

The 'host' will broadcast out with a destination MAC as 00-00-00-00-00-00 with a destination IP of the remote host, when translated to Ethernet this ARP request turns to a L2 broadcast, ultimately it reaches the gateway. The gateway then responds saying destination IP of intended host, with the default gateways MAC address as the destination.

this only applies if proxy arp is enabled.

 

see here: http://www.cisco.com/c/en/us/support/docs/ip/dynamic-address-allocation-resolution/13718-5.html

Please rate useful posts & remember to mark any solved questions as answered. Thank you.

Hello Bilal

Maybe I didnt explain it in a good way -( i never do .lol)

What i was trying to say is - Any destinaton outside  the soucre vlan the packet will be sent to the DG ( if one is defined) via an arp lookup of the DG ip address - and then forwarded

However is no DG is not defined and proxy arp isnt enabled then the packet will be dropped.

res

Paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul
Review Cisco Networking for a $25 gift card