VyOS CLI edit mode
- Matt Sherif

- 3 hours ago
- 2 min read
In a previous post we talked about VyOS as an alternative to vIOS images in EVE-NG. But it got me thinking, maybe you want to use VyOS at work or in your homelab as a router for your environment - as opposed to just a virtual environment, then this article is a good starting point.
VyOS Command Line Interface:
As I mentioned previously, VyOS uses a "JunOS style" command line interface, with some differences (e.g. JunOS uses "show configuration | display set" whereas VyOS uses "show configuration commands"), but over all it feels a lot like JunOS.
If this is your first time using a JunOS style CLI, then this could feel problematic. Take for example the below NAT configuration:
set nat destination rule 10 destination address '10.220.47.231'
set nat destination rule 10 inbound-interface name 'eth13'
set nat destination rule 10 log
set nat destination rule 10 translation address '192.168.250.1'As a newcomer to a JunOS style CLI, you might think you need to type 'set nat destination rule 10' and the following command for every line. And that would work, but I'd rather not have to type repetitive text each time, this is where the 'edit' command comes into play. The same commands above could be entered like this:
vyos@vyos# edit nat destination rule 10
[edit nat destination rule 10]
vyos@vyos# set destination address '10.220.47.231'
vyos@vyos# set inbound-interface name 'eth13'
vyos@vyos# set log
vyos@vyos# set translation address '192.168.250.1'By entering in to "edit" mode for DNAT rule 10, we only have to type in the relevant commands for that rule, reducing repetitive typing - and potential for errors. This is especially helpful when you're adding new configuration and don't have the relevant commands.
Below is another example for BGP:
vyos@vyos# edit protocols bgp
[edit protocols bgp]
vyos@vyos# run show config commands
set address-family ipv4-unicast network 0.0.0.0/0
set neighbor 10.0.0.2 address-family ipv4-unicast
set neighbor 10.0.0.2 remote-as '65001'
set neighbor 10.0.0.6 address-family ipv4-unicast
set neighbor 10.0.0.6 remote-as '65002'
set system-as '65000'
[edit protocols bgp]
vyos@vyos#I did something a little different here, and that was using the 'run' command to run 'show commands' from the configuration stanza. This is akin to doing 'do show run | s router bgp' on cisco, but with more intelligence. As you can see it showed the commands from the perspective of my 'edit' statement, which is a pretty useful capability.
Conclusion:
The VyOS command line edit mode is pretty powerful and can be extremely helpful, especially since the CLI is object aware. Using this capability can be extremely time saving and reduce the potential for errors.




Comments