Replace option via CLI - can you do it?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Replace option via CLI - can you do it?

L4 Transporter

Hi.

I have a situation on my PAN where I need to replace all instances of a given IP address (it's a "Next Hop" address in the virtual router) with a different IP address.

Through the GUI, I can only delete and re-enter all the access routes - time consuming, given there are about 35 of them concernedf with this change.

Is there a command from the CLI will is the equivalent of Juniper's "replace" command which allows you to do a search/replace for all given instances of a string int he current running configuration?

I've searched the CLI guide but can't seem to find anything obvious.

Failing that, is tehre a way via the GUI to edit/replace all instances of a next-hop address other than deleting each access-route and re-entering it?

Thanks

5 REPLIES 5

Cyber Elite
Cyber Elite

To do a mass replace you could export the config file from the device tab, open the file in any text editor, replace all instances you want to replace and reimport the file back onto the device .

Tom Piens
PANgurus - Strata specialist; config reviews, policy optimization

L0 Member

The following works for me in PAN-OS 4.0.2

# change the output format of the CLI

set cli config-output-format set

# change to configure mode

configure

# display the current routing table

show network virtual-router default routing-table ip static-route

set network virtual-router default routing-table ip static-route network-192 destination 192.168.222.0/24

set network virtual-router default routing-table ip static-route network-192 nexthop ip-address 1.1.1.1

[edit]

# copy the output to a text editor and replace the IP

# paste the 'nexthop' lines into CLIset network virtual-router default routing-table ip static-route network-192 nexthop ip-address 1.1.1.2

# confirm the result before commiting

Thanks

Ulli

tpiens wrote:

To do a mass replace you could export the config file from the device tab, open the file in any text editor, replace all instances you want to replace and reimport the file back onto the device .

Yeah, I was hoping to avoid doing that. 🙂

The "replace" keyword is one of JunOS's most useful CLI editing features, and since PanOS appears to be at least based on JunOS I was hoping it'd have something similar in CLI.

Guess I'll do it the hard way.

Thanks.

ulli.volk wrote:

The following works for me in PAN-OS 4.0.2

Sorry, my bad - I didn't specify OS version. I haven't upgraded to the 4.x stream yet - running 3.1.8.

Thanks anyway.

Just tried it on my test box running 3.1.7, seems to works as well.

Thanks

Ulli

  • 5061 Views
  • 5 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!