Learning JUNOS from IOS - Day3 (View/Modify Configuration)

A bird in the hand is worth two in the bush

Day 3 - How to view or modify JUNOS configuration ?


Entering Configuration Mode

When you stand behind an engineer, you can identify the engineer is Cisco or Juniper guy easily. 

Most cisco engineers like to use the command 'conf t' to enter configure mode of router or switch.

router> enable
Password:
router# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
router(config)#


When you want to show any results, you don't need to exit to the privilege mode(#) to show it. You can leverage 'do' command to check the status.

router(config)# do sh ip int brief
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet1       10.17.14.195    YES manual up                    up      
GigabitEthernet2       unassigned      YES unset  administratively down down    
GigabitEthernet0       unassigned      YES manual up                    up      
Loopback0              5.5.5.5         YES manual up                    up     


As below is the common Cisco IOS configuration sample, to speak frankly, its content is much easier to read and understand by mouse scroll if you understand how to use google search engine well, you must be able to read a simple Cisco IOS configuration by yourself if you have basic CCNA knowledge.

router(config)# do sh run
Building configuration...

Current configuration : 1233 bytes
!
! Last configuration change at 08:45:57 UTC Mon Mar 31 2014 by lab
|
service timestamps debug datetime msec
service timestamps log datetime msec

service password-encryption
!
hostname router
!
...(omit)
!
line con 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 login local
!
!
end

Remove a statement

If you want to delete any statement(some statements cannot be removed, ex: line vty or physical interface) in Cisco IOS, just insert 'no' command in front of any current statement:
router# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
router(config)# no service password-encryption

Show configuration with filter

You can use the pipeline symbol '|' behind the 'show run' command, with include, exclude or other keywords to filter display or manipulate file content.

In the following example, output from the 'show tech-support' command is redirected to an existing file on Disk 1 with the file-name of "showoutput.txt." This output is added at the end of any existing data in the file.

Router# show tech-support | append disk1:showoutput.txt


The following is partial sample output of the 'show interface | begin' command that begins unfiltered output with the first line that contains the regular expression "Ethernet." 

Router# show interface | begin Ethernet

Ethernet0 is up, line protocol is up
Hardware is Lance, address is 0060.837c.6399 (bia 0060.837c.6399)
Description: ip address is 172.1.2.14 255.255.255.0
Internet address is 172.1.2.14/24


The following is partial sample output of the show | exclude command used with the show buffers command. It excludes lines that contain the regular expression "0 misses."

Router# show buffers | exclude 0 misses

Buffer elements:
398 in free list (500 max allowed)
Public buffer pools:
Small buffers, 104 bytes (total 50, permanent 50):
50 in free list (20 min, 150 max allowed)
551 hits, 3 misses, 0 trims, 0 created
Big buffers, 1524 bytes (total 50, permanent 50):
49 in free list (5 min, 150 max allowed)
Very Big buffers, 4520 bytes (total 10, permanent 10):


The following examples is the filtering result of the show running-config | include command:

Router# show running-config | include interface

interface Ethernet0/0 

interface Ethernet1/0 
interface Serial2/0 
interface Serial3/0




Entering Configuration Mode

If it is the first time you login a new juniper router, you need to type 'cli' command to switch to JUNOS operational mode at first. Then type 'configure' command to enter JUNOS configuration mode.

CLI Modes

If you log in to the device as the root user, you enter the UNIX shell, which is indicated by the percent sign (%) as the prompt. To access the Junos CLI, enter the 'cli' command at the shell prompt:

root% cli
lab@router>



The Junos CLI has two modes:
  • Operational mode--This mode displays the current status of the device. In operational mode, you enter commands to monitor and troubleshoot Junos OS and devices and network connectivity.
  • Configuration mode--A Junos device configuration is stored as a hierarchy of statements. In configuration mode, you enter these statements to define all properties of Junos OS, including interfaces, general routing information, routing protocols, flow-based security features, user access, and system and hardware properties.

Operational Mode

After logging in, you enter operational mode, which is indicated by the right angle bracket (>):

lab@router>

Configuration Mode

From operational mode, use the configure command to enter configuration mode, which is indicated by the pound sign (#):

lab@router> configure
entering configuration mode
[edit]
lab@router#


To exit configuration mode and go back to operational mode, enter exit at the prompt:

lab@router# exit
lab@router>


If you would like to remove any statement, you can user 'delete' command in front of each statement:
 
lab@router> configure

lab@router# delete system backup-router 172.16.1.253

If you would like to remove specific hierarchical level, you can user 'delete' command to remove all statements under the specific hierarchical level:
lab@router# delete routing-options

Then all statements under the routing-options will be removed.

 

Many Cisco engineers were not used to see the prompt symbol '{' and '}' as below:


lab@router> show configuration   
... policy-options {
    policy-statement Export_to_EBGP {
        from {
            protocol static;
            route-filter 10.0.0.0/8 orlonger;
        }
        then accept;
    }
}
...


I believe its not so easy to change anyone's reading behavior in a short time but we can use some JUNOS features to provide a 'flat' configuration view with line-by-line statement but not shown as hierarchical view as above.




In configuration mode, you can display the configuration as a series of configuration mode commands required to re-create the configuration. This is useful if you are not familiar with how to use configuration mode commands or if you want to cut, paste, and edit the displayed configuration.

To display the configuration as a series of configuration mode commands, which are required to re-create the configuration from the top level of the hierarchy as setcommands, issue the show configuration mode command with the display set option:

[edit interfaces fe-0/0/0]lab@router# show
unit 0 {family inet {address 192.107.1.230/24;}
}
lab@router# show | match fe-0/0/0 | display setset interfaces fe-0/0/0 unit 0 family inet address 192.107.1.230/24
To display the output of an operation mode command, such as 'show', while in configuration mode, issue the run configuration mode command and then specify the operational mode command:user@host# run show vrrp detailPhysical interface: xe-5/2/0, Unit: 0, Address: 192.168.29.10/24Interface state: up, Group: 10, State: backupPriority: 190, Advertisement interval: 3, Authentication type: simplePreempt: yes, VIP count: 1, VIP: 192.168.29.55Dead timer: 8.326, Master priority: 201, Master router: 192.168.29.254[edit interfaces xe-4/2/0 unit 0 family inet vrrp-group 27]




Reference:

Comments

Popular posts from this blog

L2TPv3 Enables Layer 2 Services for IP Networks

TCP/IP 明確擁塞通知 (ECN)

Q-in-Q(Dot1Q Tunnel) Sample Configuration