cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
3428
Views
15
Helpful
16
Replies

how to change "ip default-gateway" via ssh without losing connection

kwihangana
Level 1
Level 1

I am planning to change management IP for an svi  and  "ip default-gateway" on cisco C9200L from one subnet to the other but am afraid I might lose connection.

currently mgmt svi and ip default-gateway are on 10.117.20.x and wanted to have them changed to 10.120.20.x

any suggestions to make this smooth is much appreciated.

Thank you as I look forward to reading f

16 Replies 16

balaji.bandi
Hall of Fame
Hall of Fame

Are you connecting to the same IP address and changing the same IP address, that will break the connection.

Are you able to get the Console connection and change that (is that possible ?)

Another option I can think of is for EEM Script to run a certain Time and change the IP automatically (do not save the Config)

There is another script after an hour or so EEM to reboot the switch (in case you are not able to reach the new IP address)  - you can also reload the timer another way.

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

kwihangana
Level 1
Level 1

unfortunately,it is remote and I don't have console server installed.

will try to look into EEM option

Thanks for your help BB

no worries let us know how that goes..I have tried before this practice all good and tested.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

I have idea I dont no if it work or not, 
you can ssh to next L3 and from there if you have L2 connect to SW then you dont need GW and hence you can access to SW even if GW is change.
check this solution

I have idea I dont no if it work or not, 
you can ssh to next L3 and from there if you have L2 connect to SW then you dont need GW and hence you can access to SW even if GW is change.
check this solution.

Reza Sharifi
Hall of Fame
Hall of Fame

You may want to create a default route for the new subnet and then remove the default gateway. As long the next hop for the default route is valid, you should be able to get back to the switch. In order to add a default route, you would need to enable "ip routing" on the switch.

 ip default-gateway 10.117.20.x

ip route 0.0.0.0 0.0.0.0 10.120.20.x

Once this is completed and you can access the device, you can go back and change the default route back to default gateway or leave it as it is.

 ip default-gateway 10.120.20.x

no ip route 0.0.0.0 0.0.0.0 10.120.20.x

 

Thank you Sharifi,

make sense

I will give it a try and let you know

Much appreciated

Please proceed with caution, as most likely in the transition you will lose your connection, and you need to re-establish the connection.

 Also, since you are completely changing the subnet, make sure the route is valid. It would have been much easier if you were using the same subnet/IP.

HTH 

An alternative would be to put the config commands into a text file and then on the 9200 tftp the file to running config. This should allow all commands to be executed. As @Reza Sharifi reminds us you should proceed with caution so I suggest these steps:

1) put the commands into a text file on a machine that can function as a tftp server.

2) on 9200 use reload in 10 to schedule a reload

3) on 9200 tftp the file to running config

4) if the process was successful you should be able to access the 9200 and then cancel the scheduled reload. If the process was not successful the scheduled reload will revert back to the original working config and you can figure out why it did not work and try again.

HTH

Rick

Tried this last night and lost remote connection as soon as I typed: ip routing.

Sorry to hear that the changes did not go well. I hope that you had used my suggestion about scheduling a reload.

In reading through the discussion and focusing on the suggestion about enabling ip routing the outcome might have been predicted. The switch had been operating as layer 2 and using the default-gateway command for access to remote resources. But as soon as you enter ip routing the switch becomes a layer 3 device and the default-gateway command is ignored. I wonder if you had entered the command for the static default route before the ip routing command if things might have worked.

HTH

Rick

Thanks Richard,that's exactly how I did it,started with ip routing and lost connection immediately.

I have a couple of them to be re-iped ,am going to try again starting with default route first and ip routing second.

I will kee you posted.

I will run lab and check my suggestion.  

You might also try my suggestion of putting the commands into a text file and tftp the file to running config. (and schedule a reload before you tftp. if the changes are successful you connect again and cancel the reload and if there was some problem with the changes the reload reverts to the previous config.)

HTH

Rick
Review Cisco Networking for a $25 gift card