Tags


Ok, time to get back to IOS XR posting!  This time – Aliases!
From IOS, Aliases can sometimes make life easier on you and your support staff. In IOS XR, aliases get ramped up a bit, but first lest cover the basics.
For this example, we can create an alias to show all the IPV4 interfaces in a brief using a single command, SHV4BR
RP/0/7/CPU0:R1#conf t
Mon Apr 16 15:05:26.064 UTC
RP/0/7/CPU0:R1(config)#alias SHV4BR show ipv4 int brief
RP/0/7/CPU0:R1(config)#commit
Mon Apr 16 15:05:44.043 UTC
Now, lets test the command:
RP/0/7/CPU0:R1#shv4br

As you can seem the system will re-enter the command from the alias
RP/0/7/CPU0:R1#show ipv4 int brief
Mon Apr 16 15:05:49.094 UTC
Interface IP-Address Status Protocol
Loopback0 1.1.1.1 Up Up
Loopback100 100.100.100.100 Up Up
Loopback666 6.6.6.6 Up Up
Loopback667 6.6.6.7 Up Up
MgmtEth0/7/CPU0/0 unassigned Shutdown Down
MgmtEth0/7/CPU0/1 unassigned Shutdown Down
MgmtEth0/7/CPU0/2 unassigned Shutdown Down
GigabitEthernet0/3/0/0 unassigned Down Down
GigabitEthernet0/3/0/1 unassigned Down Down
GigabitEthernet0/3/0/2 150.1.12.1 Up Up
GigabitEthernet0/3/0/3 unassigned Up Up
MgmtEth0/6/CPU0/0 unassigned Shutdown Down
MgmtEth0/6/CPU0/1 unassigned Shutdown Down
MgmtEth0/6/CPU0/2 unassigned Shutdown Down
RP/0/7/CPU0:R1#
Now, onto a cool feature, interface alias!  This can be used to define an interface.
For example, say you have two internet connections on two different routers.  Once is an Ethernet hand-off and the other is a POS hand-off.  Instead of having to remember what interface is on which router, you could just call the interface Internet.  When you or your support staff need to look at things, they just need to know to look at Internet and not which interface is on which router.  Ok, that is a use case – now onto how to do this!
We will create an alias for interface GigabitEthernet0/3/0/2, our connection to R2 on this router.
RP/0/7/CPU0:R1#conf t
Mon Apr 16 15:23:26.451 UTC
RP/0/7/CPU0:R1(config)#alias R2Connection gig0/3/0/2
RP/0/7/CPU0:R1(config)#commit
Now, lets see what happens when we do a show int for that alias
RP/0/7/CPU0:R1#sh int r2connection
RP/0/7/CPU0:R1#sh int gig0/3/0/2
Mon Apr 16 15:24:00.745 UTC
GigabitEthernet0/3/0/2 is up, line protocol is up
<— SNIP —>
0 output buffer failures, 0 output buffers swapped out
5 carrier transitions
Pretty neat, but it gets better – we can actually configure that alias as well!
RP/0/7/CPU0:R1#conf t
Mon Apr 16 15:24:06.626 UTC
RP/0/7/CPU0:R1(config)#int r2connection
RP/0/7/CPU0:R1(config)#int gig0/3/0/2
RP/0/7/CPU0:R1(config-if)#exit
RP/0/7/CPU0:R1(config)#exit
RP/0/7/CPU0:R1#
Now, there is another trick with IOS XR, and that is variables!
So, what can we do with Variables and Aliases?  Well, if there is a command that you use quite often – say show interface, why not change it to an alias with a variable.
For this example, we will create sint (show interface) and use variable (var1).
(oh, and yes I changed to a different router for this command, so please excuse the different router names)
But first, let us look at what happens when you add a question mark (?) to the end of the command in configuration mode:
RP/0/RSP0/CPU0:r1.lab(config)#alias sint ?
  LINE  Alias body with optional parameters e.g,(name) show $name
As you can see, it even tells you that you can use variables, might not be obvious, that that is what (name) is.
So, let us create our alias sint.  Notice that the command structure has the intial variable to be defined in parenthesizes ( ) and then it is called using string ($)
RP/0/RSP0/CPU0:r1.lab(config)#alias sint (var1) show interface $var1
RP/0/RSP0/CPU0:r1.lab(config)#commit
RP/0/RSP0/CPU0:r1.lab(config)#
Now we can test it on Interface Bundle-Eth 100. Notice that the Bundle-Eth100 is in parenthesizes as well (bundele-eth100).  That is how the system knows its the variable to use for this command.
RP/0/RSP0/CPU0:r1.lab#sint(Bundle-Eth100)
RP/0/RSP0/CPU0:r1.lab#show interface Bundle-Eth100
Bundle-Ether100 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Aggregated Ethernet interface(s), address is 6c9c.dead.beef
  Internet address is 192.168.1.1/30
  MTU 1514 bytes, BW 20000000 Kbit (Max: 20000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,
  Full-duplex, 20000Mb/s
  loopback not set,
  ARP type ARPA, ARP timeout 04:00:00
    No. of members in this bundle: 2
        TenGigE0/0/0/0       Full-duplex      10000Mb/s    Active            
        TenGigE0/1/0/0       Full-duplex      10000Mb/s    Active            
  Last input 00:00:00, output 00:00:00
  Last clearing of “show interface” counters never
  5 minute input rate 1000 bits/sec, 1 packets/sec
  5 minute output rate 1000 bits/sec, 1 packets/sec
     1509709 packets input, 641971670 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 5 broadcast packets, 1298355 multicast packets
              0 runts, 0 giants, 0 throttles, 0 parity
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     1518092 packets output, 642666596 bytes, 0 total output drops
     Output 6 broadcast packets, 1300886 multicast packets
     0 output errors, 0 underruns, 0 applique, 0 resets
     0 output buffer failures, 0 output buffers swapped out
     0 carrier transitions
RP/0/RSP0/CPU0:r1.lab#
Now, another trick we can do is nested aliases!
Lets modify the alias sint to show the interface as well as the running configuration.
RP/0/RSP0/CPU0:r1.lab(config)#alias sint (var1) show interface $var1; show run int $var1
RP/0/RSP0/CPU0:r1.lab(config)#commit
RP/0/RSP0/CPU0:r1.lab(config)#
Now we can test it on Bundle-Eth 100 again.
RP/0/RSP0/CPU0:r1.lab#sint(bundle-eth100)
RP/0/RSP0/CPU0:r1.lab#show interface bundle-eth100
Bundle-Ether100 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Aggregated Ethernet interface(s), address is 6c9c.dead.beef
  Internet address is 192.168.1.1/30
  MTU 1514 bytes, BW 20000000 Kbit (Max: 20000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,
  Full-duplex, 20000Mb/s
  loopback not set,
  ARP type ARPA, ARP timeout 04:00:00
    No. of members in this bundle: 2
        TenGigE0/0/0/0       Full-duplex      10000Mb/s    Active            
        TenGigE0/1/0/0       Full-duplex      10000Mb/s    Active            
  Last input 00:00:00, output 00:00:00
  Last clearing of “show interface” counters never
  5 minute input rate 1000 bits/sec, 1 packets/sec
  5 minute output rate 1000 bits/sec, 1 packets/sec
     1509849 packets input, 642030906 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 5 broadcast packets, 1298474 multicast packets
              0 runts, 0 giants, 0 throttles, 0 parity
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     1518235 packets output, 642727790 bytes, 0 total output drops
     Output 6 broadcast packets, 1301008 multicast packets
     0 output errors, 0 underruns, 0 applique, 0 resets
     0 output buffer failures, 0 output buffers swapped out
     0 carrier transitions
RP/0/RSP0/CPU0:r1.lab#show run int bundle-eth100
interface Bundle-Ether100
 ipv4 address 192.168.1.1 255.255.255.252
 bundle load-balancing hash src-ip
 bundle maximum-active links 2
 bundle minimum-active links 1
!
RP/0/RSP0/CPU0:r1.lab#
There is no question, Aliases can make your life and the life of your support staff easier!