VyOS CLI - Operational Mode and Configuration
VyOS provides a powerful command-line interface for managing the system. The CLI consists of two main modes: operational mode and configuration mode.
Operational Mode
Operational mode is used to perform system tasks and to inspect the state of the system and its services.
Key Characteristics
- Lets you perform system tasks without changing the configuration
- Provides a built-in help system
- Supports command auto-completion
Getting Help
Use ? to view the available commands:
vyos@vyos:~$ ?
Possible completions:
clear Clear system information
configure Enter configuration mode
force Force an operation
monitor Monitor system information
ping Send ICMP echo requests
reset Reset a service
restart Restart a service
show Show system information
telnet Telnet to a node
traceroute Track network path to nodeAuto-Completion
Use the TAB key to auto-complete commands:
vyos@vyos:~$ sh<TAB>
vyos@vyos:~$ showCommand Families
clear
Non-destructive actions, such as resetting counters or clearing logs:
vyos@vyos:~$ clear interfaces ethernet eth0 countersreset
Locally destructive actions, such as terminating sessions:
vyos@vyos:~$ reset vpn ipsec-peer 192.0.2.1restart
Restarting subsystems:
vyos@vyos:~$ restart service sshforce
Forcing certain system actions:
vyos@vyos:~$ force arp-cache refreshexecute
Running diagnostic and helper tasks:
vyos@vyos:~$ execute ping 8.8.8.8show
Displaying system information:
vyos@vyos:~$ show interfaces
vyos@vyos:~$ show ip route
vyos@vyos:~$ show versionmonitor
Continuous output of information (real-time updates):
vyos@vyos:~$ monitor interfaces ethernet eth0 traffic
vyos@vyos:~$ monitor logTo exit monitoring mode, use Ctrl+C.
Configuration Mode
Configuration mode is used to make changes to the system configuration.
Entering Configuration Mode
vyos@vyos:~$ configure
[edit]
vyos@vyos#Note how the command prompt changes from ~$ to #.
Basic Configuration Commands
set
Add or modify a configuration item:
vyos@vyos# set interfaces ethernet eth0 address 192.168.1.1/24
vyos@vyos# set interfaces ethernet eth0 description 'LAN Interface'delete
Remove a configuration item:
vyos@vyos# delete interfaces ethernet eth0 address 192.168.1.1/24commit
Apply configuration changes:
vyos@vyos# commitImportant: Changes do not take effect until you run the commit command.
save
Save the configuration permanently:
vyos@vyos# save
Saving configuration to '/config/config.boot'...
DoneBy default, the configuration is saved to /config/config.boot.
compare
View the differences between the current working and active configurations:
vyos@vyos# compare
[edit interfaces ethernet eth0]
+address 192.168.1.1/24
+description "LAN Interface"exit discard
Exit configuration mode without saving changes:
vyos@vyos# exit discard
vyos@vyos:~$exit
Exit configuration mode while keeping the changes:
vyos@vyos# commit
vyos@vyos# exit
vyos@vyos:~$Navigating the Configuration Hierarchy
The VyOS configuration is organized as a tree hierarchy.
edit
Move to a specific configuration level:
vyos@vyos# edit interfaces ethernet eth0
[edit interfaces ethernet eth0]
vyos@vyos#Now all commands run in the context of interfaces ethernet eth0:
[edit interfaces ethernet eth0]
vyos@vyos# set address 192.168.1.1/24
vyos@vyos# set description 'LAN Interface'up
Move up one level:
[edit interfaces ethernet eth0]
vyos@vyos# up
[edit interfaces]
vyos@vyos#top
Move to the root configuration level:
[edit interfaces ethernet eth0]
vyos@vyos# top
[edit]
vyos@vyos#exit
Exit up one level (similar to up):
[edit interfaces ethernet eth0]
vyos@vyos# exit
[edit interfaces]
vyos@vyos#Configuration Management
Configuration History
VyOS automatically keeps a history of configurations. View the list of saved revisions:
vyos@vyos# show system commit
0 2024-10-13 15:30:45 by vyos via cli
1 2024-10-13 14:15:22 by vyos via cli
2 2024-10-13 12:05:10 by vyos via cliConfiguration Rollback
Roll back to a previous configuration revision:
vyos@vyos# rollback 1
vyos@vyos# commitRoll back to the last saved configuration:
vyos@vyos# rollback
vyos@vyos# commitComparing Configurations
Compare the current configuration with a saved revision:
vyos@vyos# compare 1Compare two saved revisions:
vyos@vyos# compare 1 2Configuration Comments
Add comments to configuration items for documentation purposes:
vyos@vyos# comment interfaces ethernet eth0 address 192.168.1.1/24 "Primary LAN address"View comments:
vyos@vyos# show interfaces ethernet eth0
/* Primary LAN address */
address 192.168.1.1/24
description "LAN Interface"Commit Confirm
For critical changes, you can use a confirmation with a timeout. If the changes are not confirmed within the specified time, the configuration is rolled back automatically:
vyos@vyos# commit-confirm 5Confirm the changes within 5 minutes:
vyos@vyos# confirmThis is useful when changing the network settings of a remote router, so that you avoid losing access.
Viewing the Configuration
show
View the current configuration:
vyos@vyos# showView a specific part of the configuration:
vyos@vyos# show interfaces
vyos@vyos# show interfaces ethernet eth0show | commands
Display the configuration as set commands:
vyos@vyos# show interfaces ethernet eth0 | commands
set interfaces ethernet eth0 address '192.168.1.1/24'
set interfaces ethernet eth0 description 'LAN Interface'This is useful for copying a configuration or building scripts.
show | display-set
An alternative way to display the configuration as set commands:
vyos@vyos# show | display-setLoading a Configuration
load
Load a configuration from a file:
vyos@vyos# load /config/backup-config.bootMerge a configuration from a file into the current one:
vyos@vyos# merge /config/additional-config.bootConfiguration Archiving
Local Archiving
VyOS automatically saves every committed revision of the configuration.
Configure the number of retained revisions:
set system config-management commit-archive location '/config/archive'
set system config-management commit-revisions 50Remote Archiving
Configure automatic upload of the configuration to a remote server after every commit:
set system config-management commit-archive location 'scp://user@192.0.2.100/backup'Tips and Recommendations
Keyboard Shortcuts
TAB- auto-complete a command?- show available commandsCtrl+A- move to the beginning of the lineCtrl+E- move to the end of the lineCtrl+U- delete everything to the left of the cursorCtrl+K- delete everything to the right of the cursorCtrl+W- delete the word to the left of the cursorCtrl+L- clear the screenCtrl+C- interrupt the command
Command History
- Up/Down arrow - navigate through command history
Ctrl+R- search the command history
Pipelines
Commands can be piped to filter their output:
vyos@vyos# show | grep address
vyos@vyos# show | match "192.168"Available filters:
match- show lines that contain the patternexcept- exclude lines that contain the patterncommands- show as set commands
Copy and Paste
When working over a remote session, use copy/paste of the configuration in the form of set commands:
vyos@vyos# show interfaces ethernet eth0 | commandsCopy the output and paste it into another VyOS system.
Example Workflow
A typical configuration change process:
# 1. Enter configuration mode
vyos@vyos:~$ configure
[edit]
# 2. Make changes
vyos@vyos# set interfaces ethernet eth1 address 192.168.2.1/24
vyos@vyos# set interfaces ethernet eth1 description 'DMZ'
# 3. Review the changes
vyos@vyos# compare
# 4. Apply the changes
vyos@vyos# commit
# 5. Save the configuration
vyos@vyos# save
# 6. Exit configuration mode
vyos@vyos# exit
vyos@vyos:~$Next Steps
Now that you are familiar with the CLI, continue with:
- Configuration Overview - understanding the configuration structure
- Configuration - detailed guide to configuring components
- Operational Mode - advanced operational commands