We’re going to take a look at the basics of the juniper CLI as well as the configuration hierarchy. juniper devices run the junos operating system junos can be configured through the CLI or the web interface and also supports automation through netconf or rest one of the major benefits to junos is that it’s used across all juniper routers switches and firewalls this means that we have the same basic commands on any device the slight exception to this is on some of their older switches which use different commands to the newer ones this was before juniper created els or enhanced layer 2 services which unified these commands across all platforms we can connect to juniper devices the same way we would to any other device which includes a console port telnet ssh or through a web browser juniper cli has two modes first we have operational mode which is where we run show commands ping and anything else that operates the device we know we’re in operational mode because of greater than symbol in the prompt the second mode is configuration mode this is where all the configuration of the device is done we switch from operational mode to configuration mode with the configure command we can now see that we have the hash or pound symbol in the prompt, we can leave configuration mode with the exit command.
if at any time you get stuck there are some inbuilt help commands you can use help reference to learn about other commands notice here that we can use the question mark to see available options if you were used to Linux you’ll probably notice that this looks like the man command this is because junos is built on top of freebsd or Linux depending on the version if you have no idea which commands you need to use then you can type help propose to search to the command, you need and I sincerely hope that I pronounce that correctly help topic can give us more information on the features and configuration tasks and finally you get simple tips with help tip CLI not something I use very often honestly of course you can tab complete your commands and variables as in most clis when I say variable I mean things like the name of a policy that we have chosen a bonus feature in junos is being able to space complete commands as well it’s not like ios there’s no shortened commands every time you press space the cli will try to fill in the rest of the command for you if you really want you can disable space complete but personally I love it I said a moment ago that junos was built on freebsd or linux well we can even connect to the underlying shell if we want with this start she’ll command notice that prompt changes to a percent sign from here we can run the regular linux commands like pwd cd for changing directory and ls for a directory listing when you’re done in the shell type exits to return to the juno cli and of course the journal cli supports the regular emacs keyboard shortcuts as shown here I recommend getting comfortable with them if you’re not already if nothing else just get started by using control a and control e.
the junos configuration hierarchy is where it really starts to get interesting it’s a lot more structured than some other vendors which make it a lot easier to work within the long run it looks like a file system full of directories and files each piece of config is grouped into an area For example, one of the top-level areas is called system and under that is an area called login and under that is an area for each user here we can see some sample configuration is easy to get intimidated by this at first because it looks a bit like a programming language of some kind but don’t worry it’s really not that hard the curly braces are used to group configuration into areas often there are child groups nested within parent groups anything that ends with a semicolon is a configuration item this is just a setting of some sort if we compare this to the corresponding Cisco IOS config we see that the junos config looks longer but is far more organized the IOS config is partially hierarchical which we can see when some sections are indented but a lot of the settings are just floating around as you start getting used to the junos hierarchy you’ll start to see how useful this structure is anytime you want to see the configuration from operational mode just use show configuration this is paginated by default if we pipe through no more it will show us all the output at once when we’re in configuration mode we can see the configuration with just the show command we can also pipe through match and accept to filter output match shows any line that matches our phrase except we’ll show lines that don‘t match our phrase there are a few other cool options to you can see a few of those listed on the screen if you need to run an operational mode command like ping from configuration mode just put the command run at the start of the line this is like the do command in IOS remember how i said that the hierarchy is like a file system well we can navigate around it like a file system to we can use the edit command to move into a configuration group just like, we would use cd on windows or Linux to change a directory as soon as we do this the label above the prompt will update to show our current to location moving deeper into the config continues to update this label when we run the show command from here it is relative to our position in the config, so we don‘t see the full configuration just the parts within system login we can use up to go up one level or top to go straight to the root of the hierarchy when we want to configure something we use the set command For example, we can set the host name sorry that’s host hyphen name these commands are relative to our position in the hierarchy, we have to include system as we’re at the top of the hierarchy the opposite to set is delete this is like using the no command on a Cisco router here we’re using delete to remove one of our user accounts sorry it looks like that user doesn‘t exist we can use the question mark to find out our valid options ok we can remove the user admin 2. Nearly all set commands run from configuration mode the only exception that I know of is the set CLI commands which run from operational mode and control how do we interact with the CLI you may have noticed that the hostname hasn‘t changed yet even though we just said it this is because junos uses a commit model this means that configuration changes aren‘t applied immediately when we’re ready to apply our changes we need to run the commit command this process does a few checks to make sure our config is fine, and then applies the changes this also writes the changes to disk so there’s no need for commands like to write memory or copy run start if you would like to try all this out for yourself there’s a guided lab on the website that you can use this one’s pretty simple, but I warn you that they will get trickier as we move through the series here’s the first quiz of the series when you see these pause the article and see if you can think your way through each of these questions you’re welcome to try to work these out yourselves or discuss them in the comments section if you want to or you can always head over to the members section on the website to get detailed answers and explanations check the article description for a link hopefully the CLI will no longer seem as foreign to you as it once did one of the best parts of the juniper CLI is the commit model which we’re going to look at further in part 5. We’ll also look at configuration management further in part 6. Please click the article shown here to move on to part 3 where we’ll take our CLI skills further by configuring some interfaces and a VLAN or two.