cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9617
Views
25
Helpful
4
Comments
Aleksandar Vidakovic
Cisco Employee
Cisco Employee

     

    Introduction

    This functionality was introduced starting with IOS XR release 5.3.1 through CSCte81345.

    Just like any other configuration command, it requires a "commit" command to have the configuration stored in sysdb. The "commit" is omitted in examples provided below for brevity.

    Example 1: Replace Interface

    Starting configuration:

    !
    hostname fella
    group test
     interface 'GigabitEthernet*'
      description grouped
      mtu 500
     !
    end-group
    ipv4 access-list mylist
     10 permit tcp 10.20.30.40/16 host 1.2.4.5
     20 deny ipv4 any 1.2.3.6/16
    !
    class-map match-any c1
     match precedence 2 
     match dscp 7 
     end-class-map
    !
    policy-map p1
     class c1
      police rate 800000 bps 
      !
     !
     class class-default
      shape average 90000 bps 
     !
     end-policy-map
    !
    interface GigabitEthernet0/0/0/0
     description first
     ipv4 address 10.20.30.40 255.255.0.0
     shutdown
    !
    interface GigabitEthernet0/0/0/1
     shutdown
    !
    interface GigabitEthernet0/0/0/2
     description 10.20.30.40
     shutdown
    !
    interface GigabitEthernet0/0/0/3
     description 1020304050607080
     shutdown
    !
    interface GigabitEthernet0/0/0/4
     description 1.2.3.4.5.6.7.8
     shutdown
    !
    route-policy temp
      if ospf-area is 10.20.30.40 or source in (2.3.4.5/20) then
        pass
      endif
    end-policy
    !
    router ospf 10
     cost 100
     area 200
      cost 200
      interface GigabitEthernet0/0/0/0
       transmit-delay 5
      !
     !
    !
    router bgp 1
    !
    end
    

    Replace every occurence of "gigabitEthernet 0/0/0/0 with "loopback 450":

    RP/0/0/CPU0:fella(config)#replace interface gigabitEthernet 0/0/0/0 with loopback 450           
    Building configuration...
    Loading.
    232 bytes parsed in 1 sec (230)bytes/sec
    RP/0/0/CPU0:fella(config-ospf-ar-if)#
    

    Result (showing only the modified sections):

    RP/0/0/CPU0:fella(config-ospf-ar-if)#show conf
    Wed Feb 25 18:27:16.110 PST
    Building configuration...
    !! IOS XR Configuration 0.0.0
    interface Loopback450
     description first
     ipv4 address 10.20.30.40 255.255.0.0
     shutdown
    !
    no interface GigabitEthernet0/0/0/0
    router ospf 10
     area 200
      interface Loopback450
       transmit-delay 5
      !
      no interface GigabitEthernet0/0/0/0
     !
    !
    end
    

    Example 2: Replace pattern

    Staring from the same initial configuration as in example #1, replace every occurence of "10.20.30.40" with "100.200.250.225":

    RP/0/0/CPU0:fella(config)#replace pattern '10.20.30.40' with '100.200.250.225'
    Building configuration...
    Loading.
    434 bytes parsed in 1 sec (430)bytes/sec
    

    Result (showing only the modified sections):

    RP/0/0/CPU0:fella(config)#show conf
    Thu Feb 26 09:00:11.180 PST
    Building configuration...
    !! IOS XR Configuration 0.0.0
    ipv4 access-list mylist
     no 10
     10 permit tcp 100.200.250.225/16 host 1.2.4.5
    !
    interface GigabitEthernet0/0/0/0
     no ipv4 address 10.20.30.40 255.255.0.0
     ipv4 address 100.200.250.225 255.255.0.0
    !
    interface GigabitEthernet0/0/0/2
     no description
     description 100.200.250.225
    !
    !
    route-policy temp
      if ospf-area is 100.200.250.225 or source in (2.3.4.5/20) then
        pass
      endif
    end-policy
    !
    end
    

    Example 3: Replace Pattern Using Regular Expressions

    The desired wildcard effect can be produced using the more powerful "replace pattern", which can take POSIX compliant regular expressions. Take this config as start:

    RP/0/0/CPU0:ios#sh run
    Fri Feb 27 16:49:39.126 PST
    Building configuration...
    !! IOS XR Configuration 0.0.0
    !! Last configuration change at Fri Feb 27 16:49:27 2015 by UNKNOWN
    !
    interface GigabitEthernet0/0/0/0
     ipv4 address 10.0.0.10 255.255.0.0
    !
    interface GigabitEthernet0/0/0/1
     ipv4 address 11.0.0.11 255.255.0.0
    !
    interface GigabitEthernet0/0/0/2
     ipv4 address 12.0.0.12 255.255.0.0
    !
    interface GigabitEthernet0/0/0/3
     ipv4 address 13.0.0.13 255.255.0.0
    !
    interface GigabitEthernet0/0/0/4
     ipv4 address 14.0.0.14 255.255.0.0
    !
    interface GigabitEthernet0/1/0/0
     ipv4 address 20.0.0.10 255.255.0.0
    !
    interface TenGigE0/3/0/0
     shutdown
    !
    interface TenGigE0/3/0/1
     shutdown
    !
    interface TenGigE0/3/0/2
     shutdown
    !
    interface TenGigE0/3/0/3
     shutdown
    !
    interface TenGigE0/3/0/4
     shutdown
    !
    interface TenGigE0/3/0/5
     shutdown
    !
    interface TenGigE0/3/0/6
     shutdown
    !
    end
    

    Using replace pattern 'GigabitEthernet0/1/0/([0-4]*)' with 'TenGigE0/3/0/\1', interfaces GigabitEthernet0/0/0/0 through GigabitEthernet0/0/0/4 are replaced with TenGigE0/3/0/0 through TenGigE0/3/0/4:

    RP/0/0/CPU0:ios(config)#replace pattern 'GigabitEthernet0/1/0/([0-4]*)' with 'TenGigE0/3/0/\1'  
    Building configuration...
    Loading.
    485 bytes parsed in 1 sec (482)bytes/sec
    

    Result:

    RP/0/0/CPU0:ios(config-if)#show conf
    Fri Feb 27 16:52:56.549 PST
    Building configuration...
    !! IOS XR Configuration 0.0.0
    no interface GigabitEthernet0/1/0/0
    no interface GigabitEthernet0/1/0/1
    no interface GigabitEthernet0/1/0/2
    no interface GigabitEthernet0/1/0/3
    no interface GigabitEthernet0/1/0/4
    interface TenGigE0/3/0/0
     ipv4 address 20.0.0.10 255.255.0.0
    !
    interface TenGigE0/3/0/1
     ipv4 address 21.0.0.11 255.255.0.0
    !
    interface TenGigE0/3/0/2
     ipv4 address 22.0.0.12 255.255.0.0
    !
    interface TenGigE0/3/0/3
     ipv4 address 23.0.0.13 255.255.0.0
    !
    interface TenGigE0/3/0/4
     ipv4 address 24.0.0.14 255.255.0.0
    !
    End

    Example 4: Additional Syntax Check

    If you want to be extra cautious and see the result before it's actually applied, you can use the dry-run option. This option immediately shows the final configuration, i.e. you don't have to run the "show conf" from the configuration mode to see the modified configuration.

    RP/0/RSP0/CPU0:our9001(config)#replace pattern '1.1.1.1' with '2.2.2.2' dry-run
    vrf VOICE
     address-family ipv4 unicast
      import route-target
       no 121:121
       2.2.2.2
      export route-target
       no 121:121
       2.2.2.2
    interface tunnel-te10
     no autoroute destination 1.1.1.1
     autoroute destination 2.2.2.2
    end
    

     

    Comments
    Tom Marcoen
    Level 1
    Level 1

    Great new feature! I'm really looking forward to upgrading our ASRs to 5.3.x.

    Brent Crier
    Level 1
    Level 1

    Very cool. Although I'm not a fan that it removes the interface from the config when you place the interface. I think a better option would have been un-configure it.

    RP/0/0/CPU0:ios(config)#replace pattern 'GigabitEthernet0/1/0/([0-4]*)' with 'TenGigE0/3/0/\1' 

    Aleksandar Vidakovic
    Cisco Employee
    Cisco Employee

    hi Brent,

    thanks for the feedback. We have decided for the removal because it was easier to implement and it was better serving the use case of virtual interfaces. You are bringing up a valid point in case of physical interfaces. Were you indeed referring to physical interfaces?

    Regards,

    Aleksandar

    ciromarciano
    Level 1
    Level 1

    Hi Aleksandar,

     it is possible to use this command to change a range of interfaces?

    An example: the goal is to move the configuration under interfaces GigabitEthernet 0/1/0/5 --> 0/1/0/10 to interface TenGigE 0/3/0/5 --> 0/3/0/10.

    Thank you

    Ciro

    Getting Started

    Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

    Quick Links