diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-14 02:05:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-14 02:05:25 +0300 |
| commit | c1b22cfa8cc2b7afaa97e66ec573b293cfb77556 (patch) | |
| tree | 766b8b18ce43b8d845b672039bccdcb90f4a78de /docs | |
| parent | c6af2fed6e538ad43d13464e87cdd2b39ffad3d3 (diff) | |
| parent | 9340e43951d20c388f1d627b1e003a25529067f4 (diff) | |
| download | vyos-documentation-c1b22cfa8cc2b7afaa97e66ec573b293cfb77556.tar.gz vyos-documentation-c1b22cfa8cc2b7afaa97e66ec573b293cfb77556.zip | |
Merge pull request #2022 from vyos/yuriy/finish-conversion-sagitta
docs(sagitta): finish RST→MD conversion — port cli + aws from rolling
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_templates/llms.txt.j2 | 7 | ||||
| -rw-r--r-- | docs/cli.md | 868 | ||||
| -rw-r--r-- | docs/cli.rst | 1054 | ||||
| -rw-r--r-- | docs/installation/cloud/aws.md | 188 | ||||
| -rw-r--r-- | docs/installation/cloud/aws.rst | 693 |
5 files changed, 1057 insertions, 1753 deletions
diff --git a/docs/_templates/llms.txt.j2 b/docs/_templates/llms.txt.j2 index dd112ae4..3b16121c 100644 --- a/docs/_templates/llms.txt.j2 +++ b/docs/_templates/llms.txt.j2 @@ -11,12 +11,7 @@ VyOS configuration follows a tree structure. All configuration commands start wi ## Quick Start - [Quick Start Guide]({{ baseurl }}quick-start.md): Minimal setup walkthrough -{# cli.html (not cli.md) — sagitta's `docs/cli.rst` hasn't been - migrated to MyST (rst-to-myst chokes on the heading hierarchy in - that file), so no `.md` source is copied to the HTML root by - `_copy_md_sources`. Pin this one entry to `.html` until cli.rst is - migrated; tracked as a separate cleanup PR. -#} -- [CLI Overview]({{ baseurl }}cli.html): Command-line interface usage +- [CLI Overview]({{ baseurl }}cli.md): Command-line interface usage ## Configuration diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 00000000..e961c790 --- /dev/null +++ b/docs/cli.md @@ -0,0 +1,868 @@ +(cli)= + +# Command Line Interface + +The VyOS {abbr}`CLI (Command-Line Interface)` comprises an operational and a configuration mode. + +## Operational Mode + +Operational mode allows for commands to perform operational system tasks and view system and service status, while configuration mode allows for the modification of system configuration. + +The CLI provides a built-in help system. In the CLI the `?` key may be used to display available commands. The `TAB` key can be used to auto-complete commands and will present the help system upon a conflict or unknown value. + +For example typing `sh` followed by the `TAB` key will complete to `show`. Pressing `TAB` a second time will display the possible sub-commands of the `show` command. + +``` none +vyos@vyos:~$ s[tab] +set show +``` + +Example showing possible show commands: + +``` none +vyos@vyos:~$ show [tab] +Possible completions: + arp Show Address Resolution Protocol (ARP) information + bridge Show bridging information + cluster Show clustering information + configuration Show running configuration + conntrack Show conntrack entries in the conntrack table + conntrack-sync + Show connection syncing information + date Show system date and time + dhcp Show Dynamic Host Configuration Protocol (DHCP) information + dhcpv6 Show status related to DHCPv6 + disk Show status of disk device + dns Show Domain Name Server (DNS) information + file Show files for a particular image + firewall Show firewall information + flow-accounting + Show flow accounting statistics + hardware Show system hardware details + history show command history + host Show host information + incoming Show ethernet input-policy information +: q +``` + +You can scroll up with the keys `[Shift]+[PageUp]` and scroll down with `[Shift]+[PageDown]`. + +When the output of a command results in more lines than can be displayed on the terminal screen the output is paginated as indicated by a `:` prompt. + +When viewing in page mode the following commands are available: +: - `q` key can be used to cancel output + - `space` will scroll down one page + - `b` will scroll back one page + - `return` will scroll down one line + - `up-arrow` and `down-arrow` will scroll up or down one line at a time + respectively + - `left-arrow` and `right-arrow` can be used to scroll left or right in + the event that the output has lines which exceed the terminal size. + +### Operational mode command families + +Many operational mode commands in VyOS are placed in families such as `show`, `clear`, or `reset`. Every such family has a specific meaning to allow the user to guess how the command is going to behave --- in particular, whether it will be disruptive to the system or not. + +Note that this convention was not always followed with perfect consistency and some commands may still be in wrong families, so you should always check the command help and documentation if you are not sure what exactly it does. + +#### clear + +\"Clear\" commands are completely non-disruptive to any system operations. Generally, they can be used freely without hesitation. + +Most often their purpose is to remove or reset various debug and diagnostic information such as system logs and packet counters. + +Examples: +- `clear console` --- clears the screen. +- `clear interfaces ethernet eth0 counters` --- zeroes packet counters on `eth0`. +- `clear log` --- deletes all system log entries. + +#### reset + +\"Reset\" commands can be locally-disruptive. They may, for example, terminate a single user session or a session with a dynamic routing protocol peer. + +They should be used with caution since they may have a significant impact on a particular users in the network. +- `reset pppoe-server username jsmith` --- terminate all PPPoE sessions from user `jsmith`. +- `reset bgp 192.0.2.54` --- terminates the BGP session with neighbor 192.0.2.54. +- `reset vpn ipsec site-to-site peer vpn.example.com` --- terminates IPsec tunnels to `vpn.example.com`. +- `reset session tty1` --- terminates the TTY user session `tty1` + +#### restart + +\"Restart\" operations may disrupt an entire subsystem. Most often they initiate a restart of a server process, which causes it to be unavailable for a brief period and resets all the process state. + +They should be used with extreme caution. +- `restart dhcp server` --- restarts the IPv4 DHCP server process (DHCP requests are not served while it is restarting). +- `restart ipsec` --- restarts the IPsec process (which forces all sessions and all IPsec process state to reset). + +#### force + +\"Force\" commands force the system to perform an action that it might perform by itself at a later point. + +Examples: +- `force arp request interface eth1 address 10.3.0.2` --- send a gratuitous ARP request. +- `force root-partition-auto-resize` --- grow the root filesystem to the size of the system partition (this is also done on startup, but this command can do it without a reboot). + +#### execute + +\"Execute\" commands are for executing various diagnostic and auxiliary actions that the system would never perform by itself. + +Examples: +- `execute wake-on-lan interface <intf> host <MAC>` --- send a Wake-On-LAN packet to a host. + +#### show + +\"Show\" commands display various system information. They may occasionally use a pager for long outputs, that you can quit by pressing the Q button. Their output is always finite, however. + +Examples: +- `show system login` --- displays current system users. +- `show ip route` --- displays the IPv4 routing table. + +#### monitor + +\"Monitor\" commands initiate various monitoring operations that may output information continuously, until terminated with `Ctrl-C` or disabled. + +Examples: +- `monitor log` --- continuously outputs latest system logs. + +## Configuration Mode + +To enter configuration mode use the `configure` command: + +``` none +vyos@vyos:~$ configure +[edit] +vyos@vyos:~# +``` + +::::{note} +Prompt changes from `$` to `#`. To exit configuration mode, type `exit`. +:::: + +``` none +vyos@vyos:~# exit +exit +vyos@vyos:~$ +``` + +See the configuration section of this document for more information on configuration mode. + +(configuration-overview)= + +# Configuration Overview + +VyOS makes use of a unified configuration file for the entire system\'s configuration: `/config/config.boot`. This allows easy template creation, backup, and replication of system configuration. A system can thus also be easily cloned by simply copying the required configuration files. + +## Terminology + +A VyOS system has three major types of configurations: +- **Active** or **running configuration** is the system configuration that is loaded and currently active (used by VyOS). Any change in the configuration will have to be committed to belong to the active/running configuration. +- **Working configuration** is the one that is currently being modified in configuration mode. Changes made to the working configuration do not go into effect until the changes are committed with the {cfgcmd}`commit` command. At which time the working configuration will become the active or running configuration. +- **Saved configuration** is the one saved to a file using the {cfgcmd}`save` command. It allows you to keep safe a configuration for future uses. There can be multiple configuration files. The default or \"boot\" configuration is saved and loaded from the file `/config/config.boot`. + +## Seeing and navigating the configuration + +```{opcmd} show configuration + +View the current active configuration, also known as the running configuration, from the operational mode. + +:::{code-block} none +vyos@vyos:~$ show configuration +interfaces { + ethernet eth0 { + address dhcp + hw-id 00:53:00:00:aa:01 + } + loopback lo { + } +} +service { + ssh { + port 22 + } +} +system { + config-management { + commit-revisions 20 + } + console { + device ttyS0 { + speed 9600 + } + } + login { + user vyos { + authentication { + encrypted-password **************** + } + level admin + } + } + ntp { + server 0.pool.ntp.org { + } + server 1.pool.ntp.org { + } + server 2.pool.ntp.org { + } + } + syslog { + global { + facility all { + level notice + } + facility protocols { + level debug + } + } + } +} +::: +``` + +By default, the configuration is displayed in a hierarchy like the above example, this is only one of the possible ways to display the configuration. When the configuration is generated and the device is configured, changes are added through a collection of {cfgcmd}`set` and {cfgcmd}`delete` commands. + +```{opcmd} show configuration commands + +Get a collection of all the set commands required which led to the running configuration. + +:::{code-block} none +vyos@vyos:~$ show configuration commands +set interfaces ethernet eth0 address 'dhcp' +set interfaces ethernet eth0 hw-id '00:53:dd:44:3b:0f' +set interfaces loopback 'lo' +set service ssh port '22' +set system config-management commit-revisions '20' +set system console device ttyS0 speed '9600' +set system login user vyos authentication encrypted-password '$6$Vt68...QzF0' +set system login user vyos level 'admin' +set system ntp server '0.pool.ntp.org' +set system ntp server '1.pool.ntp.org' +set system ntp server '2.pool.ntp.org' +set system syslog global facility all level 'notice' +set system syslog global facility protocols level 'debug' +::: +``` + +Both these `show` commands should be executed when in operational mode, they do not work directly in configuration mode. There is a special way on how to {ref}`run_opmode_from_config_mode`. + +::::{hint} + +Use the `show configuration commands | strip-private` command when you want to hide private data. You may want to do so if you want to share your configuration on the [forum](https://forum.vyos.io). +:::: + +```{opcmd} show configuration json + +View the current active configuration in JSON format. + +:::{code-block} none +{"interfaces": {"ethernet": {"eth0": {"address": ["192.0.2.11/24", "192.0.2.35/24"], "hw-id": "52:54:00:48:a0:c6"}, "eth1": {"address": ["203.0.113.1/24"], "hw-id": "52:54:00:fc:50:0b"}}, "loopback": {"lo": {}}}, "protocols": {"static": {"route": {"0.0.0.0/0": {"next-hop": {"192.0.2.254": {}}}}}}, "service": {"ssh": {"disable-host-validation": {}}}, "system": {"config-management": {"commit-revisions": "100"}, "console": {"device": {"ttyS0": {"speed": "115200"}}}, "host-name": "r11-vyos", "login": {"user": {"vyos": {"authentication": {"encrypted-password": "$6$Vt68...F0", "plaintext-password": "", "public-keys": {"vyos@vyos": {"key": "AAAAxxx=", "type": "ssh-rsa"}}}}}}, "name-server": ["203.0.113.254"], "ntp": {"server": {"time1.vyos.net": {}, "time2.vyos.net": {}, "time3.vyos.net": {}}}, "syslog": {"global": {"facility": {"all": {"level": "info"}, "protocols": {"level": "debug"}}}}, "time-zone": "America/New_York"}} +::: +``` + +```{opcmd} show configuration json pretty + +View the current active configuration in readable JSON format. + +:::{code-block} none +{ + "interfaces": { + "ethernet": { + "eth0": { + "address": [ + "192.0.2.11/24", + "192.0.2.35/24" + ], + "hw-id": "52:54:00:48:a0:c6" + }, + "eth1": { + "address": [ + "203.0.113.1/24" + ], + "hw-id": "52:54:00:fc:50:0b" + } + }, + "loopback": { + "lo": {} + } + }, + "protocols": { + "static": { + "route": { + "0.0.0.0/0": { + "next-hop": { + "192.0.2.254": {} + } + } + } + } + }, + "service": { + "ssh": { + "disable-host-validation": {} + } + }, + "system": { + "config-management": { + "commit-revisions": "100" + }, + "console": { + "device": { + "ttyS0": { + "speed": "115200" + } + } + }, + "host-name": "r11-vyos", + "login": { + "user": { + "vyos": { + "authentication": { + "encrypted-password": "$6$Vt68...F0", + "plaintext-password": "", + "public-keys": { + "vyos@vyos": { + "key": "AAAAxxx=", + "type": "ssh-rsa" + } + } + } + } + } + }, + "name-server": [ + "203.0.113.254" + ], + "ntp": { + "server": { + "time1.vyos.net": {}, + "time2.vyos.net": {}, + "time3.vyos.net": {} + } + }, + "syslog": { + "global": { + "facility": { + "all": { + "level": "info" + }, + "protocols": { + "level": "debug" + } + } + } + }, + "time-zone": "America/New_York" + } +} +::: +``` + + +### The config mode + +When entering the configuration mode you are navigating inside a tree structure, to enter configuration mode enter the command {opcmd}`configure` when in operational mode. + +``` none +vyos@vyos$ configure +[edit] +vyos@vyos# +``` + +::::{note} +When going into configuration mode, prompt changes from `$` to `#`. +:::: + +All commands executed here are relative to the configuration level you have entered. You can do everything from the top level, but commands will be quite lengthy when manually typing them. + +The current hierarchy level can be changed by the {cfgcmd}`edit` command. + +``` none +[edit] +vyos@vyos# edit interfaces ethernet eth0 + +[edit interfaces ethernet eth0] +vyos@vyos# +``` + +You are now in a sublevel relative to `interfaces ethernet eth0`, all commands executed from this point on are relative to this sublevel. Use either the {cfgcmd}`top` or {cfgcmd}`exit` command to go back to the top of the hierarchy. You can also use the {cfgcmd}`up` command to move only one level up at a time. + +```{cfgcmd} show +``` + +The {cfgcmd}`show` command within configuration mode will show the working configuration indicating line changes with `+` for additions, `>` for replacements and `-` for deletions. +**Example:** + +``` none +vyos@vyos:~$ configure +[edit] +vyos@vyos# show interfaces + ethernet eth0 { + description MY_OLD_DESCRIPTION + disable + hw-id 00:53:dd:44:3b:03 + } + loopback lo { + } +[edit] +vyos@vyos# set interfaces ethernet eth0 address dhcp +[edit] +vyos@vyos# set interfaces ethernet eth0 description MY_NEW_DESCRIPTION +[edit] +vyos@vyos# delete interfaces ethernet eth0 disable +[edit] +vyos@vyos# show interfaces + ethernet eth0 { ++ address dhcp +> description MY_NEW_DESCRIPTION +- disable + hw-id 00:53:dd:44:3b:03 + } + loopback lo { + } +``` + +It is also possible to display all {cfgcmd}`set` commands within configuration mode using {cfgcmd}`show | commands` + +``` none +vyos@vyos# show interfaces ethernet eth0 | commands +set address dhcp +set hw-id 00:53:ad:44:3b:03 +``` + +These commands are also relative to the level you are inside and only relevant configuration blocks will be displayed when entering a sub-level. + +``` none +[edit interfaces ethernet eth0] +vyos@vyos# show + address dhcp + hw-id 00:53:ad:44:3b:03 +``` + +Exiting from the configuration mode is done via the {cfgcmd}`exit` command from the top level, executing {cfgcmd}`exit` from within a sub-level takes you back to the top level. + +``` none +[edit interfaces ethernet eth0] +vyos@vyos# exit +[edit] +vyos@vyos# exit +Warning: configuration changes have not been saved. +``` + +## Editing the configuration + +The configuration can be edited by the use of {cfgcmd}`set` and {cfgcmd}`delete` commands from within configuration mode. + +```{cfgcmd} set + +Use this command to set the value of a parameter or to create a new element. +``` + +Configuration commands are flattened from the tree into \'one-liner\' commands shown in {opcmd}`show configuration commands` from operation mode. Commands are relative to the level where they are executed and all redundant information from the current level is removed from the command entered. + +``` none +[edit] +vyos@vyos# set interface ethernet eth0 address 192.0.2.100/24 +``` + +``` none +[edit interfaces ethernet eth0] +vyos@vyos# set address 203.0.113.6/24 +``` + +These two commands above are essentially the same, just executed from different levels in the hierarchy. + +```{cfgcmd} delete + +To delete a configuration entry use the {cfgcmd}`delete` command, this also deletes all sub-levels under the current level you\'ve specified in the {cfgcmd}`delete` command. Deleting an entry will also result in the element reverting back to its default value if one exists. + +:::{code-block} none +[edit interfaces ethernet eth0] +vyos@vyos# delete address 192.0.2.100/24 +::: +``` + +```{cfgcmd} commit + +Any change you do on the configuration, will not take effect until committed using the {cfgcmd}`commit` command in configuration mode. + +:::{code-block} none +vyos@vyos# commit +[edit] +vyos@vyos# exit +Warning: configuration changes have not been saved. +vyos@vyos:~$ +::: +``` +::::{hint} + +You can specify a commit message with {cfgcmd}`commit comment <message>`. +:::: + +(save)= + +```{cfgcmd} save + +Use this command to preserve configuration changes upon reboot. By default it is stored at */config/config.boot*. In the case you want to store the configuration file somewhere else, you can add a local path, a SCP address, a FTP address or a TFTP address. +``` + +``` none +vyos@vyos# save +Saving configuration to '/config/config.boot'... +Done +``` + +``` none +vyos@vyos# save [tab] +Possible completions: + <Enter> Save to system config file + <file> Save to file on local machine + scp://<user>:<passwd>@<host>:/<file> Save to file on remote machine + ftp://<user>:<passwd>@<host>/<file> Save to file on remote machine + tftp://<host>/<file> Save to file on remote machine +vyos@vyos# save tftp://192.168.0.100/vyos-test.config.boot +Saving configuration to 'tftp://192.168.0.100/vyos-test.config.boot'... + +Done +``` +::: +:::: +```{cfgcmd} exit \[discard\] + +Configuration mode can not be exited while uncommitted changes exist. To exit configuration mode without applying changes, the {cfgcmd}`exit discard` command must be used. + +All changes in the working config will thus be lost. + +:::{code-block} none +vyos@vyos# exit +Cannot exit: configuration modified. + +Use 'exit discard' to discard the changes and exit. +[edit] +vyos@vyos# exit discard +::: +``` + +```{cfgcmd} commit-confirm \<minutes\> + +Use this command to temporarily commit your changes and set the number of minutes available for confirmation. `confirm` must be entered within those minutes, otherwise the system will revert into a previous configuration. The default value is 10 minutes. + +The definition of \'revert\' and \'a previous configuration\' depends on the setting: + +:::{code-block} none +vyos@vyos# set system config-management commit-confirm action +Possible completions: +reload Reload previous configuration if not confirmed +reboot Reboot to saved configuration if not confirmed (default) +::: + +Note that \'reload\' loads the most recent completed configuration and does not require a reboot. + +What if you are doing something dangerous? Suppose you want to setup a firewall, and you are not sure there are no mistakes that will lock you out of your system. You can use confirmed commit. If you issue the `commit-confirm` command, your changes will be committed, and if you don\'t issue the `confirm` command in 10 minutes, your system will reboot into previous config revision. + +:::{code-block} none +vyos@router# set firewall interface eth0 local name FromWorld +vyos@router# commit-confirm +commit confirm will be automatically reboot in 10 minutes unless confirmed +Proceed? [confirm]y +[edit] +vyos@router# confirm +[edit] +::: +``` + +```{cfgcmd} copy + +Copy a configuration element. + +You can copy and remove configuration subtrees. Suppose you set up a firewall ruleset `FromWorld` with one rule that allows traffic from specific subnet. Now you want to setup a similar rule, but for different subnet. Change your edit level to `firewall name FromWorld` and use `copy rule 10 to rule 20`, then modify rule 20. + +:::{code-block} none +vyos@router# show firewall name FromWorld + default-action drop + rule 10 { + action accept + source { + address 203.0.113.0/24 + } + } +[edit] +vyos@router# edit firewall name FromWorld +[edit firewall name FromWorld] +vyos@router# copy rule 10 to rule 20 +[edit firewall name FromWorld] +vyos@router# set rule 20 source address 198.51.100.0/24 +[edit firewall name FromWorld] +vyos@router# commit +[edit firewall name FromWorld] +::: +``` + +```{cfgcmd} rename + +Rename a configuration element. + +You can also rename config subtrees: + +:::{code-block} none +vyos@router# rename rule 10 to rule 5 +[edit firewall name FromWorld] +vyos@router# commit +[edit firewall name FromWorld] +::: +Note that `show` command respects your edit level and from this level you can view the modified firewall ruleset with just `show` with no parameters. + +:::{code-block} none +vyos@router# show + default-action drop + rule 5 { + action accept + source { + address 203.0.113.0/24 + } + } + rule 20 { + action accept + source { + address 198.51.100.0/24 + } + } +::: +``` + +```{cfgcmd} comment \<config node\> "comment text" + +Add comment as an annotation to a configuration node. + +The `comment` command allows you to insert a comment above the `<config node>` configuration section. When shown, comments are enclosed with `/*` and `*/` as open/close delimiters. Comments need to be committed, just like other config changes. + +To remove an existing comment from your current configuration, specify an empty string enclosed in double quote marks (`""`) as the comment text. + +Example: + +:::{code-block} none +vyos@vyos# comment firewall all-ping "Yes I know this VyOS is cool" +vyos@vyos# commit +vyos@vyos# show + firewall { + /* Yes I know this VyOS is cool */ + all-ping enable + broadcast-ping disable + ... + } +::: +:::{note} +An important thing to note is that since the comment is added on top of the section, it will not appear if the `show <section>` command is used. With the above example, the ``show firewall`` command would return starting after the `firewall {` line, hiding the comment. +::: +``` + +(run_opmode_from_config_mode)= + +## Access opmode from config mode + +When inside configuration mode you are not directly able to execute operational commands. + +```{cfgcmd} run + +Access to these commands are possible through the use of the `run [command]` command. From this command you will have access to everything accessible from operational mode. + +Command completion and syntax help with `?` and `[tab]` will also work. + +:::{code-block} none +[edit] +vyos@vyos# run show interfaces +Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down +Interface IP Address S/L Description +--------- ---------- --- ----------- +eth0 0.0.0.0/0 u/u +::: +``` + +## Managing configurations + +VyOS comes with an integrated versioning system for the system configuration. It automatically maintains a backup of every previous configuration which has been committed to the system. The configurations are versioned locally for rollback but they can also be stored on a remote host for archiving/backup reasons. + +### Local Archive + +Revisions are stored on disk. You can view, compare and rollback them to any previous revisions if something goes wrong. + +```{opcmd} show system commit + +View all existing revisions on the local system. + +:::{code-block} none +vyos@vyos:~$ show system commit +0 2015-03-30 08:53:03 by vyos via cli +1 2015-03-30 08:52:20 by vyos via cli +2 2015-03-26 21:26:01 by root via boot-config-loader +3 2015-03-26 20:43:18 by root via boot-config-loader +4 2015-03-25 11:06:14 by root via boot-config-loader +5 2015-03-25 01:04:28 by root via boot-config-loader +6 2015-03-25 00:16:47 by vyos via cli +7 2015-03-24 23:43:45 by root via boot-config-loader +::: +``` + +```{cfgcmd} set system config-management commit-revisions \<N\> + +You can specify the number of revisions stored on disk. N can be in the range of 0 - 65535. When the number of revisions exceeds the configured value, the oldest revision is removed. The default setting for this value is to store 100 revisions locally. +``` + +### Compare configurations + +VyOS lets you compare different configurations. + +```{cfgcmd} compare \<saved \| N\> \<M\> + +Use this command to spot what the differences are between different configurations. + +:::{code-block} none +vyos@vyos# compare [tab] +Possible completions: +<Enter> Compare working & active configurations +saved Compare working & saved configurations +<N> Compare working with revision N +<N> <M> Compare revision N with M +Revisions: + 0 2013-12-17 20:01:37 root by boot-config-loader + 1 2013-12-13 15:59:31 root by boot-config-loader + 2 2013-12-12 21:56:22 vyos by cli + 3 2013-12-12 21:55:11 vyos by cli + 4 2013-12-12 21:27:54 vyos by cli + 5 2013-12-12 21:23:29 vyos by cli + 6 2013-12-12 21:13:59 root by boot-config-loader + 7 2013-12-12 16:25:19 vyos by cli + 8 2013-12-12 15:44:36 vyos by cli + 9 2013-12-12 15:42:07 root by boot-config-loader + 10 2013-12-12 15:42:06 root by init +::: +The command {cfgcmd}`compare` allows you to compare different type of configurations. It also lets you compare different revisions through the {cfgcmd}`compare N M` command, where N and M are revision numbers. The output will describe how the configuration N is when compared to M indicating with a plus sign (`+`) the additional parts N has when compared to M, and indicating with a minus sign (`-`) the lacking parts N misses when compared to M. + +:::{code-block} none +vyos@vyos# compare 0 6 +[edit interfaces] ++dummy dum1 { ++ address 10.189.0.1/31 ++} +[edit interfaces ethernet eth0] ++vif 99 { ++ address 10.199.0.1/31 ++} +-vif 900 { +- address 192.0.2.4/24 +-} +::: +``` + +```{opcmd} show system commit diff \<number\> + +Show commit revision difference. +``` + +The command above also lets you see the difference between two commits. By default the difference with the running config is shown. + +``` none +vyos@router# run show system commit diff 4 +[edit system] ++ipv6 { ++ disable-forwarding ++} +``` + +This means four commits ago we did `set system ipv6 disable-forwarding`. + +### Rollback Changes + +You can rollback configuration changes using the rollback command. This will apply the selected revision and trigger a system reboot. + +```{cfgcmd} rollback \<N\> + +Rollback to revision N (currently requires reboot) + +:::{code-block} none +vyos@vyos# compare 1 +[edit system] +>host-name vyos-1 +[edit] +vyos@vyos# rollback 1 +Proceed with reboot? [confirm][y] +Broadcast message from root@vyos-1 (pts/0) (Tue Dec 17 21:07:45 2013): + +The system is going down for reboot NOW! +::: +``` + +### Remote Archive + +VyOS can upload the configuration to a remote location after each call to {cfgcmd}`commit`. You will have to set the commit-archive location. TFTP, FTP, SCP and SFTP servers are supported. Every time a {cfgcmd}`commit` is successful the `config.boot` file will be copied to the defined destination(s). The filename used on the remote host will be `config.boot-hostname.YYYYMMDD_HHMMSS`. + +```{cfgcmd} set system config-management commit-archive location \<URI\> + +Specify remote location of commit archive as any of the below {abbr}`URI (Uniform Resource Identifier)` +- `http://<user>:<passwd>@<host>:/<dir>` +- `https://<user>:<passwd>@<host>:/<dir>` +- `ftp://<user>:<passwd>@<host>/<dir>` +- `sftp://<user>:<passwd>@<host>/<dir>` +- `scp://<user>:<passwd>@<host>:/<dir>` +- `tftp://<host>/<dir>` +- `git+https://<user>:<passwd>@<host>/<path>` + +Since username and password are part of the URI, they need to be properly url encoded if containing special characters. + +:::{note} +The number of revisions don\'t affect the commit-archive. + +When using Git as destination for the commit archive the `source-address` CLI option has no effect. + +You may find VyOS not allowing the secure connection because it cannot verify the legitimacy of the remote server. You can use the workaround below to quickly add the remote host\'s SSH fingerprint to your `~/.ssh/known_hosts` file: +::: +:::{code-block} none +vyos@vyos# ssh-keyscan <host> >> ~/.ssh/known_hosts +::: +``` + +```{cfgcmd} set system config-management commit-archive vrf \<name\> + +Specify name of the {abbr}`VRF (Virtual Routing and Forwarding)` instance used to upload the configuration to the remote system. +``` + +### Saving and loading manually + +You can use the `save` and `load` commands if you want to manually manage specific configuration files. + +When using the [save](#save) command, you can add a specific location where to store your configuration file. And, when needed it, you will be able to load it with the `load` command: + +```{cfgcmd} load \<URI\> + +Use this command to load a configuration which will replace the running configuration. Define the location of the configuration file to be loaded. You can use a path to a local file, an SCP address, an SFTP address, an FTP address, an HTTP address, an HTTPS address or a TFTP address. + +:::{code-block} none +vyos@vyos# load +Possible completions: +<Enter> Load from system config file +<file> Load from file on local machine +scp://<user>:<passwd>@<host>:/<file> Load from file on remote machine +sftp://<user>:<passwd>@<host>/<file> Load from file on remote machine +ftp://<user>:<passwd>@<host>/<file> Load from file on remote machine +http://<host>/<file> Load from file on remote machine +https://<host>/<file> Load from file on remote machine +tftp://<host>/<file> Load from file on remote machine +::: + +If you are remotely connected, you will lose your connection. You may want to copy first the config, edit it to ensure connectivity, and load the edited config. +``` + +### Restore Default + +In the case you want to completely delete your configuration and restore the default one, you can enter the following command in configuration mode: + +``` none +load /opt/vyatta/etc/config.boot.default +``` + +You will be asked if you want to continue. If you accept, you will have to use {cfgcmd}`commit` if you want to make the changes active. + +Then you may want to {cfgcmd}`save` in order to delete the saved configuration too. + +::::{note} +Prompt changes from `$` to `#`. To exit configuration mode, type `exit`. +:::: diff --git a/docs/cli.rst b/docs/cli.rst deleted file mode 100644 index 8169cbd5..00000000 --- a/docs/cli.rst +++ /dev/null @@ -1,1054 +0,0 @@ -.. _cli: - -###################### -Command Line Interface -###################### - -The VyOS :abbr:`CLI (Command-Line Interface)` comprises an operational and a -configuration mode. - -Operational Mode -################ - -Operational mode allows for commands to perform operational system tasks and -view system and service status, while configuration mode allows for the -modification of system configuration. - -The CLI provides a built-in help system. In the CLI the ``?`` key may be used -to display available commands. The ``TAB`` key can be used to auto-complete -commands and will present the help system upon a conflict or unknown value. - -For example typing ``sh`` followed by the ``TAB`` key will complete to -``show``. Pressing ``TAB`` a second time will display the possible -sub-commands of the ``show`` command. - -.. code-block:: none - - vyos@vyos:~$ s[tab] - set show - -Example showing possible show commands: - -.. code-block:: none - - vyos@vyos:~$ show [tab] - Possible completions: - arp Show Address Resolution Protocol (ARP) information - bridge Show bridging information - cluster Show clustering information - configuration Show running configuration - conntrack Show conntrack entries in the conntrack table - conntrack-sync - Show connection syncing information - date Show system date and time - dhcp Show Dynamic Host Configuration Protocol (DHCP) information - dhcpv6 Show status related to DHCPv6 - disk Show status of disk device - dns Show Domain Name Server (DNS) information - file Show files for a particular image - firewall Show firewall information - flow-accounting - Show flow accounting statistics - hardware Show system hardware details - history show command history - host Show host information - incoming Show ethernet input-policy information - : q - -You can scroll up with the keys ``[Shift]+[PageUp]`` and scroll down with -``[Shift]+[PageDown]``. - -When the output of a command results in more lines than can be displayed on the -terminal screen the output is paginated as indicated by a ``:`` prompt. - -When viewing in page mode the following commands are available: - * ``q`` key can be used to cancel output - * ``space`` will scroll down one page - * ``b`` will scroll back one page - * ``return`` will scroll down one line - * ``up-arrow`` and ``down-arrow`` will scroll up or down one line at a - time respectively - * ``left-arrow`` and ``right-arrow`` can be used to scroll left or right - in the event that the output has lines which exceed the terminal size. - -Operational mode command families -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Many operational mode commands in VyOS are placed in families such as -``show``, ``clear``, or ``reset``. Every such family has a specific -meaning to allow the user to guess how the command is going to behave — -in particular, whether it will be disruptive to the system or not. - -Note that this convention was not always followed with perfect -consistency and some commands may still be in wrong families, so you -should always check the command help and documentation if you are not -sure what exactly it does. - -clear -''''' - -"Clear" commands are completely non-disruptive to any system operations. -Generally, they can be used freely without hesitation. - -Most often their purpose is to remove or reset various debug and -diagnostic information such as system logs and packet counters. - -Examples: - -- ``clear console`` — clears the screen. -- ``clear interfaces ethernet eth0 counters`` — zeroes packet counters - on ``eth0``. -- ``clear log`` — deletes all system log entries. - -reset -''''' - -"Reset" commands can be locally-disruptive. They may, for example, -terminate a single user session or a session with a dynamic routing -protocol peer. - -They should be used with caution since they may have a significant -impact on a particular users in the network. - -- ``reset pppoe-server username jsmith`` — terminate all PPPoE sessions - from user ``jsmith``. -- ``reset bgp 192.0.2.54`` — terminates the BGP session with neighbor - 192.0.2.54. -- ``reset vpn ipsec site-to-site peer vpn.example.com`` — terminates - IPsec tunnels to ``vpn.example.com``. - -restart -''''''' - -"Restart" operations may disrupt an entire subsystem. Most often they -initiate a restart of a server process, which causes it to be -unavailable for a brief period and resets all the process state. - -They should be used with extreme caution. - -- ``restart dhcp server`` — restarts the IPv4 DHCP server process (DHCP - requests are not served while it is restarting). -- ``restart ipsec`` — restarts the IPsec process (which forces all - sessions and all IPsec process state to reset). - -force -''''' - -"Force" commands force the system to perform an action that it might -perform by itself at a later point. - -Examples: - -- ``force arp request interface eth1 address 10.3.0.2`` — send a - gratuitious ARP request. -- ``force root-partition-auto-resize`` — grow the root filesystem to - the size of the system partition (this is also done on startup, but - this command can do it without a reboot). - -execute -''''''' - -"Execute" commands are for executing various diagnostic and auxilliary -actions that the system would never perform by itself. - -Examples: - -- ``execute wake-on-lan interface <intf> host <MAC>`` — send a - Wake-On-LAN packet to a host. - -show -'''' - -"Show" commands display various system information. They may -occasionally use a pager for long outputs, that you can quit by pressing -the Q button. Their output is always finite, however. - -Examples: - -- ``show system login`` — displays current system users. -- ``show ip route`` — displays the IPv4 routing table. - -monitor -''''''' - -"Monitor" commands initiate various monitoring operations that may -output information continuously, until terminated with ``Ctrl-C`` or -disabled. - -Examples: - -- ``monitor log`` — continuously outputs latest system logs. - - -Configuration Mode -################## - -To enter configuration mode use the ``configure`` command: - -.. code-block:: none - - vyos@vyos:~$ configure - [edit] - vyos@vyos:~# - -.. note:: Prompt changes from ``$`` to ``#``. To exit configuration mode, - type ``exit``. - -.. code-block:: none - - vyos@vyos:~# exit - exit - vyos@vyos:~$ - -See the configuration section of this document for more information on -configuration mode. - - -.. _configuration-overview: - -###################### -Configuration Overview -###################### - -VyOS makes use of a unified configuration file for the entire system's -configuration: ``/config/config.boot``. This allows easy template -creation, backup, and replication of system configuration. A system can -thus also be easily cloned by simply copying the required configuration -files. - -Terminology -########### - -A VyOS system has three major types of configurations: - -* **Active** or **running configuration** is the system configuration - that is loaded and currently active (used by VyOS). Any change in - the configuration will have to be committed to belong to the - active/running configuration. - -* **Working configuration** is the one that is currently being modified - in configuration mode. Changes made to the working configuration do - not go into effect until the changes are committed with the - :cfgcmd:`commit` command. At which time the working configuration will - become the active or running configuration. - -* **Saved configuration** is the one saved to a file using the - :cfgcmd:`save` command. It allows you to keep safe a configuration for - future uses. There can be multiple configuration files. The default or - "boot" configuration is saved and loaded from the file - ``/config/config.boot``. - -Seeing and navigating the configuration -======================================= - -.. opcmd:: show configuration - - View the current active configuration, also known as the running - configuration, from the operational mode. - - .. code-block:: none - - vyos@vyos:~$ show configuration - interfaces { - ethernet eth0 { - address dhcp - hw-id 00:53:00:00:aa:01 - } - loopback lo { - } - } - service { - ssh { - port 22 - } - } - system { - config-management { - commit-revisions 20 - } - console { - device ttyS0 { - speed 9600 - } - } - login { - user vyos { - authentication { - encrypted-password **************** - } - level admin - } - } - ntp { - server 0.pool.ntp.org { - } - server 1.pool.ntp.org { - } - server 2.pool.ntp.org { - } - } - syslog { - global { - facility all { - level notice - } - facility protocols { - level debug - } - } - } - } - -By default, the configuration is displayed in a hierarchy like the above -example, this is only one of the possible ways to display the -configuration. When the configuration is generated and the device is -configured, changes are added through a collection of :cfgcmd:`set` and -:cfgcmd:`delete` commands. - -.. opcmd:: show configuration commands - - Get a collection of all the set commands required which led to the - running configuration. - - .. code-block:: none - - vyos@vyos:~$ show configuration commands - set interfaces ethernet eth0 address 'dhcp' - set interfaces ethernet eth0 hw-id '00:53:dd:44:3b:0f' - set interfaces loopback 'lo' - set service ssh port '22' - set system config-management commit-revisions '20' - set system console device ttyS0 speed '9600' - set system login user vyos authentication encrypted-password '$6$Vt68...QzF0' - set system login user vyos level 'admin' - set system ntp server '0.pool.ntp.org' - set system ntp server '1.pool.ntp.org' - set system ntp server '2.pool.ntp.org' - set system syslog global facility all level 'notice' - set system syslog global facility protocols level 'debug' - -Both these ``show`` commands should be executed when in operational -mode, they do not work directly in configuration mode. There is a -special way on how to :ref:`run_opmode_from_config_mode`. - -.. hint:: Use the ``show configuration commands | strip-private`` - command when you want to hide private data. You may want to do so if - you want to share your configuration on the `forum`_. - -.. _`forum`: https://forum.vyos.io - -.. opcmd:: show configuration json - - View the current active configuration in JSON format. - - .. code-block:: none - - {"interfaces": {"ethernet": {"eth0": {"address": ["192.0.2.11/24", "192.0.2.35/24"], "hw-id": "52:54:00:48:a0:c6"}, "eth1": {"address": ["203.0.113.1/24"], "hw-id": "52:54:00:fc:50:0b"}}, "loopback": {"lo": {}}}, "protocols": {"static": {"route": {"0.0.0.0/0": {"next-hop": {"192.0.2.254": {}}}}}}, "service": {"ssh": {"disable-host-validation": {}}}, "system": {"config-management": {"commit-revisions": "100"}, "console": {"device": {"ttyS0": {"speed": "115200"}}}, "host-name": "r11-vyos", "login": {"user": {"vyos": {"authentication": {"encrypted-password": "$6$Vt68...F0", "plaintext-password": "", "public-keys": {"vyos@vyos": {"key": "AAAAxxx=", "type": "ssh-rsa"}}}}}}, "name-server": ["203.0.113.254"], "ntp": {"server": {"time1.vyos.net": {}, "time2.vyos.net": {}, "time3.vyos.net": {}}}, "syslog": {"global": {"facility": {"all": {"level": "info"}, "protocols": {"level": "debug"}}}}, "time-zone": "America/New_York"}} - -.. opcmd:: show configuration json pretty - - View the current active configuration in readable JSON format. - - .. code-block:: none - - { - "interfaces": { - "ethernet": { - "eth0": { - "address": [ - "192.0.2.11/24", - "192.0.2.35/24" - ], - "hw-id": "52:54:00:48:a0:c6" - }, - "eth1": { - "address": [ - "203.0.113.1/24" - ], - "hw-id": "52:54:00:fc:50:0b" - } - }, - "loopback": { - "lo": {} - } - }, - "protocols": { - "static": { - "route": { - "0.0.0.0/0": { - "next-hop": { - "192.0.2.254": {} - } - } - } - } - }, - "service": { - "ssh": { - "disable-host-validation": {} - } - }, - "system": { - "config-management": { - "commit-revisions": "100" - }, - "console": { - "device": { - "ttyS0": { - "speed": "115200" - } - } - }, - "host-name": "r11-vyos", - "login": { - "user": { - "vyos": { - "authentication": { - "encrypted-password": "$6$Vt68...F0", - "plaintext-password": "", - "public-keys": { - "vyos@vyos": { - "key": "AAAAxxx=", - "type": "ssh-rsa" - } - } - } - } - } - }, - "name-server": [ - "203.0.113.254" - ], - "ntp": { - "server": { - "time1.vyos.net": {}, - "time2.vyos.net": {}, - "time3.vyos.net": {} - } - }, - "syslog": { - "global": { - "facility": { - "all": { - "level": "info" - }, - "protocols": { - "level": "debug" - } - } - } - }, - "time-zone": "America/New_York" - } - } - - -The config mode ---------------- - -When entering the configuration mode you are navigating inside a tree -structure, to enter configuration mode enter the command -:opcmd:`configure` when in operational mode. - -.. code-block:: none - - vyos@vyos$ configure - [edit] - vyos@vyos# - - -.. note:: When going into configuration mode, prompt changes from - ``$`` to ``#``. - - -All commands executed here are relative to the configuration level you -have entered. You can do everything from the top level, but commands -will be quite lengthy when manually typing them. - -The current hierarchy level can be changed by the :cfgcmd:`edit` -command. - -.. code-block:: none - - [edit] - vyos@vyos# edit interfaces ethernet eth0 - - [edit interfaces ethernet eth0] - vyos@vyos# - -You are now in a sublevel relative to ``interfaces ethernet eth0``, all -commands executed from this point on are relative to this sublevel. Use -either the :cfgcmd:`top` or :cfgcmd:`exit` command to go back to the top -of the hierarchy. You can also use the :cfgcmd:`up` command to move only -one level up at a time. - -.. cfgcmd:: show - -The :cfgcmd:`show` command within configuration mode will show the -working configuration indicating line changes with ``+`` for additions, -``>`` for replacements and ``-`` for deletions. - -**Example:** - -.. code-block:: none - - vyos@vyos:~$ configure - [edit] - vyos@vyos# show interfaces - ethernet eth0 { - description MY_OLD_DESCRIPTION - disable - hw-id 00:53:dd:44:3b:03 - } - loopback lo { - } - [edit] - vyos@vyos# set interfaces ethernet eth0 address dhcp - [edit] - vyos@vyos# set interfaces ethernet eth0 description MY_NEW_DESCRIPTION - [edit] - vyos@vyos# delete interfaces ethernet eth0 disable - [edit] - vyos@vyos# show interfaces - ethernet eth0 { - + address dhcp - > description MY_NEW_DESCRIPTION - - disable - hw-id 00:53:dd:44:3b:03 - } - loopback lo { - } - -It is also possible to display all :cfgcmd:`set` commands within configuration -mode using :cfgcmd:`show | commands` - -.. code-block:: none - - vyos@vyos# show interfaces ethernet eth0 | commands - set address dhcp - set hw-id 00:53:ad:44:3b:03 - -These commands are also relative to the level you are inside and only -relevant configuration blocks will be displayed when entering a -sub-level. - -.. code-block:: none - - [edit interfaces ethernet eth0] - vyos@vyos# show - address dhcp - hw-id 00:53:ad:44:3b:03 - -Exiting from the configuration mode is done via the :cfgcmd:`exit` -command from the top level, executing :cfgcmd:`exit` from within a -sub-level takes you back to the top level. - -.. code-block:: none - - [edit interfaces ethernet eth0] - vyos@vyos# exit - [edit] - vyos@vyos# exit - Warning: configuration changes have not been saved. - - -Editing the configuration -========================= - -The configuration can be edited by the use of :cfgcmd:`set` and -:cfgcmd:`delete` commands from within configuration mode. - -.. cfgcmd:: set - - Use this command to set the value of a parameter or to create a new - element. - -Configuration commands are flattened from the tree into 'one-liner' -commands shown in :opcmd:`show configuration commands` from operation -mode. Commands are relative to the level where they are executed and all -redundant information from the current level is removed from the command -entered. - -.. code-block:: none - - [edit] - vyos@vyos# set interface ethernet eth0 address 192.0.2.100/24 - - -.. code-block:: none - - [edit interfaces ethernet eth0] - vyos@vyos# set address 203.0.113.6/24 - - -These two commands above are essentially the same, just executed from -different levels in the hierarchy. - -.. cfgcmd:: delete - - To delete a configuration entry use the :cfgcmd:`delete` command, - this also deletes all sub-levels under the current level you've - specified in the :cfgcmd:`delete` command. Deleting an entry will - also result in the element reverting back to its default value if one - exists. - - .. code-block:: none - - [edit interfaces ethernet eth0] - vyos@vyos# delete address 192.0.2.100/24 - -.. cfgcmd:: commit - - Any change you do on the configuration, will not take effect until - committed using the :cfgcmd:`commit` command in configuration mode. - - .. code-block:: none - - vyos@vyos# commit - [edit] - vyos@vyos# exit - Warning: configuration changes have not been saved. - vyos@vyos:~$ - -.. hint:: You can specify a commit message with - :cfgcmd:`commit comment <message>`. - -.. _save: - -.. cfgcmd:: save - - Use this command to preserve configuration changes upon reboot. By - default it is stored at */config/config.boot*. In the case you want - to store the configuration file somewhere else, you can add a local - path, a SCP address, a FTP address or a TFTP address. - - .. code-block:: none - - vyos@vyos# save - Saving configuration to '/config/config.boot'... - Done - - .. code-block:: none - - vyos@vyos# save [tab] - Possible completions: - <Enter> Save to system config file - <file> Save to file on local machine - scp://<user>:<passwd>@<host>:/<file> Save to file on remote machine - ftp://<user>:<passwd>@<host>/<file> Save to file on remote machine - tftp://<host>/<file> Save to file on remote machine - vyos@vyos# save tftp://192.168.0.100/vyos-test.config.boot - Saving configuration to 'tftp://192.168.0.100/vyos-test.config.boot'... - ######################################################################## 100.0% - Done - -.. cfgcmd:: exit [discard] - - Configuration mode can not be exited while uncommitted changes exist. - To exit configuration mode without applying changes, the - :cfgcmd:`exit discard` command must be used. - - All changes in the working config will thus be lost. - - .. code-block:: none - - vyos@vyos# exit - Cannot exit: configuration modified. - Use 'exit discard' to discard the changes and exit. - [edit] - vyos@vyos# exit discard - - -.. cfgcmd:: commit-confirm <minutes> - - Use this command to temporarily commit your changes and set the - number of minutes available for validation. ``confirm`` must - be entered within those minutes, otherwise the system will reboot - into the previous configuration. The default value is 10 minutes. - - - What if you are doing something dangerous? Suppose you want to setup - a firewall, and you are not sure there are no mistakes that will lock - you out of your system. You can use confirmed commit. If you issue - the ``commit-confirm`` command, your changes will be committed, and if - you don't issue the ``confirm`` command in 10 minutes, your - system will reboot into previous config revision. - - .. code-block:: none - - vyos@router# set firewall interface eth0 local name FromWorld - vyos@router# commit-confirm - commit confirm will be automatically reboot in 10 minutes unless confirmed - Proceed? [confirm]y - [edit] - vyos@router# confirm - [edit] - - - .. note:: A reboot because you did not enter ``confirm`` will not - take you necessarily to the *saved configuration*, but to the - point before the unfortunate commit. - - -.. cfgcmd:: copy - - Copy a configuration element. - - You can copy and remove configuration subtrees. Suppose you set up a - firewall ruleset ``FromWorld`` with one rule that allows traffic from - specific subnet. Now you want to setup a similar rule, but for - different subnet. Change your edit level to - ``firewall name FromWorld`` and use ``copy rule 10 to rule 20``, then - modify rule 20. - - - .. code-block:: none - - vyos@router# show firewall name FromWorld - default-action drop - rule 10 { - action accept - source { - address 203.0.113.0/24 - } - } - [edit] - vyos@router# edit firewall name FromWorld - [edit firewall name FromWorld] - vyos@router# copy rule 10 to rule 20 - [edit firewall name FromWorld] - vyos@router# set rule 20 source address 198.51.100.0/24 - [edit firewall name FromWorld] - vyos@router# commit - [edit firewall name FromWorld] - - -.. cfgcmd:: rename - - Rename a configuration element. - - You can also rename config subtrees: - - .. code-block:: none - - vyos@router# rename rule 10 to rule 5 - [edit firewall name FromWorld] - vyos@router# commit - [edit firewall name FromWorld] - - Note that ``show`` command respects your edit level and from this - level you can view the modified firewall ruleset with just ``show`` - with no parameters. - - .. code-block:: none - - vyos@router# show - default-action drop - rule 5 { - action accept - source { - address 203.0.113.0/24 - } - } - rule 20 { - action accept - source { - address 198.51.100.0/24 - } - } - - -.. cfgcmd:: comment <config node> "comment text" - - Add comment as an annotation to a configuration node. - - The ``comment`` command allows you to insert a comment above the - ``<config node>`` configuration section. When shown, comments are - enclosed with ``/*`` and ``*/`` as open/close delimiters. Comments - need to be committed, just like other config changes. - - To remove an existing comment from your current configuration, - specify an empty string enclosed in double quote marks (``""``) as - the comment text. - - Example: - - .. code-block:: none - - vyos@vyos# comment firewall all-ping "Yes I know this VyOS is cool" - vyos@vyos# commit - vyos@vyos# show - firewall { - /* Yes I know this VyOS is cool */ - all-ping enable - broadcast-ping disable - ... - } - - .. note:: An important thing to note is that since the comment is - added on top of the section, it will not appear if the ``show - <section>`` command is used. With the above example, the `show - firewall` command would return starting after the ``firewall - {`` line, hiding the comment. - - - - - - -.. _run_opmode_from_config_mode: - -Access opmode from config mode -============================== - -When inside configuration mode you are not directly able to execute -operational commands. - -.. cfgcmd:: run - - Access to these commands are possible through the use of the - ``run [command]`` command. From this command you will have access to - everything accessible from operational mode. - - Command completion and syntax help with ``?`` and ``[tab]`` will also - work. - - .. code-block:: none - - [edit] - vyos@vyos# run show interfaces - Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down - Interface IP Address S/L Description - --------- ---------- --- ----------- - eth0 0.0.0.0/0 u/u - -Managing configurations -======================= - -VyOS comes with an integrated versioning system for the system -configuration. It automatically maintains a backup of every previous -configuration which has been committed to the system. The configurations -are versioned locally for rollback but they can also be stored on a -remote host for archiving/backup reasons. - -Local Archive -------------- - -Revisions are stored on disk. You can view, compare and rollback them to -any previous revisions if something goes wrong. - -.. opcmd:: show system commit - - View all existing revisions on the local system. - - .. code-block:: none - - vyos@vyos:~$ show system commit - 0 2015-03-30 08:53:03 by vyos via cli - 1 2015-03-30 08:52:20 by vyos via cli - 2 2015-03-26 21:26:01 by root via boot-config-loader - 3 2015-03-26 20:43:18 by root via boot-config-loader - 4 2015-03-25 11:06:14 by root via boot-config-loader - 5 2015-03-25 01:04:28 by root via boot-config-loader - 6 2015-03-25 00:16:47 by vyos via cli - 7 2015-03-24 23:43:45 by root via boot-config-loader - - -.. cfgcmd:: set system config-management commit-revisions <N> - - You can specify the number of revisions stored on disk. N can be in - the range of 0 - 65535. When the number of revisions exceeds the - configured value, the oldest revision is removed. The default setting - for this value is to store 100 revisions locally. - - -Compare configurations ----------------------- - -VyOS lets you compare different configurations. - -.. cfgcmd:: compare <saved | N> <M> - - Use this command to spot what the differences are between different - configurations. - - .. code-block:: none - - vyos@vyos# compare [tab] - Possible completions: - <Enter> Compare working & active configurations - saved Compare working & saved configurations - <N> Compare working with revision N - <N> <M> Compare revision N with M - Revisions: - 0 2013-12-17 20:01:37 root by boot-config-loader - 1 2013-12-13 15:59:31 root by boot-config-loader - 2 2013-12-12 21:56:22 vyos by cli - 3 2013-12-12 21:55:11 vyos by cli - 4 2013-12-12 21:27:54 vyos by cli - 5 2013-12-12 21:23:29 vyos by cli - 6 2013-12-12 21:13:59 root by boot-config-loader - 7 2013-12-12 16:25:19 vyos by cli - 8 2013-12-12 15:44:36 vyos by cli - 9 2013-12-12 15:42:07 root by boot-config-loader - 10 2013-12-12 15:42:06 root by init - - The command :cfgcmd:`compare` allows you to compare different type of - configurations. It also lets you compare different revisions through - the :cfgcmd:`compare N M` command, where N and M are revision - numbers. The output will describe how the configuration N is when - compared to M indicating with a plus sign (``+``) the additional - parts N has when compared to M, and indicating with a minus sign - (``-``) the lacking parts N misses when compared to M. - - .. code-block:: none - - vyos@vyos# compare 0 6 - [edit interfaces] - +dummy dum1 { - + address 10.189.0.1/31 - +} - [edit interfaces ethernet eth0] - +vif 99 { - + address 10.199.0.1/31 - +} - -vif 900 { - - address 192.0.2.4/24 - -} - - -.. opcmd:: show system commit diff <number> - - Show commit revision difference. - - -The command above also lets you see the difference between two commits. -By default the difference with the running config is shown. - -.. code-block:: none - - vyos@router# run show system commit diff 4 - [edit system] - +ipv6 { - + disable-forwarding - +} - -This means four commits ago we did ``set system ipv6 disable-forwarding``. - - -Rollback Changes ----------------- - -You can rollback configuration changes using the rollback command. This -will apply the selected revision and trigger a system reboot. - -.. cfgcmd:: rollback <N> - - Rollback to revision N (currently requires reboot) - - .. code-block:: none - - vyos@vyos# compare 1 - [edit system] - >host-name vyos-1 - [edit] - - vyos@vyos# rollback 1 - Proceed with reboot? [confirm][y] - Broadcast message from root@vyos-1 (pts/0) (Tue Dec 17 21:07:45 2013): - The system is going down for reboot NOW! - -Remote Archive --------------- - -VyOS can upload the configuration to a remote location after each call -to :cfgcmd:`commit`. You will have to set the commit-archive location. -TFTP, FTP, SCP and SFTP servers are supported. Every time a -:cfgcmd:`commit` is successful the ``config.boot`` file will be copied -to the defined destination(s). The filename used on the remote host will -be ``config.boot-hostname.YYYYMMDD_HHMMSS``. - -.. cfgcmd:: set system config-management commit-archive location <URI> - - Specify remote location of commit archive as any of the below - :abbr:`URI (Uniform Resource Identifier)` - - * ``http://<user>:<passwd>@<host>:/<dir>`` - * ``https://<user>:<passwd>@<host>:/<dir>`` - * ``ftp://<user>:<passwd>@<host>/<dir>`` - * ``sftp://<user>:<passwd>@<host>/<dir>`` - * ``scp://<user>:<passwd>@<host>:/<dir>`` - * ``tftp://<host>/<dir>`` - * ``git+https://<user>:<passwd>@<host>/<path>`` - - Since username and password are part of the URI, they need to be - properly url encoded if containing special characters. - - .. note:: The number of revisions don't affect the commit-archive. - - .. note:: When using Git as destination for the commit archive the - ``source-address`` CLI option has no effect. - - .. note:: You may find VyOS not allowing the secure connection because - it cannot verify the legitimacy of the remote server. You can use - the workaround below to quickly add the remote host's SSH - fingerprint to your ``~/.ssh/known_hosts`` file: - - .. code-block:: none - - vyos@vyos# ssh-keyscan <host> >> ~/.ssh/known_hosts - -Saving and loading manually ---------------------------- - -You can use the ``save`` and ``load`` commands if you want to manually -manage specific configuration files. - -When using the save_ command, you can add a specific location where -to store your configuration file. And, when needed it, you will be able -to load it with the ``load`` command: - -.. cfgcmd:: load <URI> - - Use this command to load a configuration which will replace the - running configuration. Define the location of the configuration file - to be loaded. You can use a path to a local file, an SCP address, an - SFTP address, an FTP address, an HTTP address, an HTTPS address or a - TFTP address. - - .. code-block:: none - - vyos@vyos# load - Possible completions: - <Enter> Load from system config file - <file> Load from file on local machine - scp://<user>:<passwd>@<host>:/<file> Load from file on remote machine - sftp://<user>:<passwd>@<host>/<file> Load from file on remote machine - ftp://<user>:<passwd>@<host>/<file> Load from file on remote machine - http://<host>/<file> Load from file on remote machine - https://<host>/<file> Load from file on remote machine - tftp://<host>/<file> Load from file on remote machine - - - -Restore Default ---------------- - -In the case you want to completely delete your configuration and restore -the default one, you can enter the following command in configuration -mode: - -.. code-block:: none - - load /opt/vyatta/etc/config.boot.default - -You will be asked if you want to continue. If you accept, you will have -to use :cfgcmd:`commit` if you want to make the changes active. - -Then you may want to :cfgcmd:`save` in order to delete the saved -configuration too. - -.. note:: If you are remotely connected, you will lose your connection. - You may want to copy first the config, edit it to ensure - connectivity, and load the edited config. - diff --git a/docs/installation/cloud/aws.md b/docs/installation/cloud/aws.md new file mode 100644 index 00000000..de5da3aa --- /dev/null +++ b/docs/installation/cloud/aws.md @@ -0,0 +1,188 @@ +--- +lastproofread: '2026-02-06' +--- + +# Amazon AWS + +## Deploy VM + +Deploy VyOS on Amazon {abbr}`AWS (Amazon Web Services)`. + +1. Click **Instances** and then click **Launch Instance**. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-01.webp +``` + +2. Search for "VyOS" in the Marketplace. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-02.webp +``` + +3. Choose the instance type. The recommended minimum is `m3.medium`. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-03.webp +``` + +4. Configure the instance for your requirements. Select the number of + instances, network, and subnet. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-04.webp +``` + +5. Configure additional storage. You can remove the additional storage + `/dev/sdb`. The root device will be `/dev/xvda`. You can skip this step. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-05.webp +``` + +6. Configure the security group. We recommend configuring SSH access + only from specific sources, or you can permit any IP address (the default). + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-06.webp +``` + +7. Select the SSH key pair and click **Launch Instances**. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-07.webp +``` + +8. Note your public IP address. + +```{eval-rst} +.. figure:: /_static/images/cloud-aws-08.webp +``` + +9. Connect to the instance using your SSH key. + +```{eval-rst} + + .. code-block:: none + + ssh -i ~/.ssh/amazon.pem vyos@203.0.113.3 + vyos@ip-192-0-2-10:~$ +``` + + +## Amazon CloudWatch Agent Usage + +To use the Amazon CloudWatch agent, configure it in the Amazon Systems Manager +Parameter Store. For instructions on creating a configuration, see +{ref}`configuration_creation`. + +1. Create an {abbr}`IAM (Identity and Access Management)` role for the + {abbr}`EC2 (Elastic Compute Cloud)` instance to access CloudWatch service, + and name it CloudWatchAgentServerRole. The role should contain two default + policies: `CloudWatchAgentServerPolicy` and + `AmazonSSMManagedInstanceCore`. +2. Attach the created role to your VyOS {abbr}`EC2 (Elastic Compute Cloud)` + instance. +3. Ensure the amazon-cloudwatch-agent package is installed. + +```{eval-rst} + + .. code-block:: none + + $ sudo apt list --installed | grep amazon-cloudwatch-agent + + .. note:: The amazon-cloudwatch-agent package is normally included in + VyOS 1.3.3+ and 1.4+ +``` + +4. Retrieve an existing CloudWatch Agent configuration from the + {abbr}`SSM (Systems Manager)` Parameter Store. + +```{eval-rst} + + .. code-block:: none + + $ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:<your-configuration-name> + + This step also enables systemd service and runs it. + + .. note:: The VyOS platform-specific scripts feature is under development. + Thus, this step should be repeated manually after changing system image + (:doc:`/installation/update`) +``` + +(configuration_creation)= + +### CloudWatch SSM Configuration creation + +Creating the Amazon Cloudwatch Agent Configuration in Amazon +{abbr}`SSM (Systems Manager)` Parameter Store. + +1. Create an {abbr}`IAM (Identity and Access Management)` role for your + {abbr}`EC2 (Elastic Compute Cloud)` instance to access the CloudWatch + service. Name it `CloudWatchAgentAdminRole`. The role must contain at + least two policies: `CloudWatchAgentAdminPolicy` and + `AmazonSSMManagedInstanceCore`. + +```{eval-rst} + + .. note:: CloudWatchAgentServerRole is too permissive and should be used only + for + creating and deploying a single configuration. After step 3, we recommend + replacing the ``CloudWatchAgentAdminRole`` with the + ``CloudWatchAgentServerRole``. +``` + +2. Run the CloudWatch configuration wizard. + +```{eval-rst} + + .. code-block:: none + + $ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard +``` + +3. When prompted, enter "yes" to the question "Do you want to store the + config in the SSM parameter store?". + +## AWS Gateway Load Balancer + +VyOS supports the AWS Gateway Load Balancer (GWLB) tunnel handler (`gwlbtun`), +which enables VyOS to act as an inspection or processing target for GWLB. GWLB +uses Geneve encapsulation with custom metadata to deliver traffic to VyOS for +packet filtering, shaping, deep packet inspection, NAT, or other traffic +manipulation functions. The tunnel handler automatically creates Linux tunnel +interfaces (`gwi-*` for ingress and `gwo-*` for egress) per endpoint, +allowing you to use standard Linux utilities like iptables, tc, and netfilter +to implement your inspection or processing logic. This enables VyOS to serve as +a centralized appliance for traffic inspection in your AWS infrastructure, +supporting both single-endpoint (1-arm) and multi-endpoint (2-arm) deployment +modes. + +For more information about integrating with AWS Gateway Load Balancer, see +the following article from AWS: +[How to integrate Linux instances with AWS Gateway Load Balancer](https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-integrate-linux-instances-with-aws-gateway-load-balancer/). + +### Configuration Example + +Configure the AWS GWLB service with the following commands: + +```none +set service aws glb script on-create '/config/scripts/glb-create.sh' +set service aws glb script on-destroy '/config/scripts/glb-destroy.sh' +set service aws glb status format 'simple' +set service aws glb status port '8282' +set service aws glb threads tunnel '4' +set service aws glb threads tunnel-affinity '1-2' +set service aws glb threads udp '4' +set service aws glb threads udp-affinity '0-3' +``` + + +## References + +- <https://console.aws.amazon.com/> +- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html> +- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance-fleet.html> +- <https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-integrate-linux-instances-with-aws-gateway-load-balancer/> + diff --git a/docs/installation/cloud/aws.rst b/docs/installation/cloud/aws.rst deleted file mode 100644 index 17ecfe16..00000000 --- a/docs/installation/cloud/aws.rst +++ /dev/null @@ -1,693 +0,0 @@ -########## -VyOS Deployment on AWS -########## - - -This manual provides detailed step-by-step instructions for deploying a VyOS instance and required resources (VPC, ENIs, Subnets, Security Groups) on AWS. - -Prerequisites -======== - -1. AWS Account ------------ -Ensure you have an AWS account with administrative access. - -2. IAM Permissions ------------ - -To deploy VyOS and related resources, the user must have the following permissions: - -- ``ec2:`` for managing EC2, ENIs, and EIPs. -- ``vpc:`` for creating VPCs, subnets, and route tables. -- ``iam:`` for attaching roles. - -3. SSH Key Pair ------------ - -You can use Amazon EC2 to create your key pairs, or you can use a third-party tool to create your key pairs and then import them to Amazon EC2. -Amazon EC2 supports: - -- ``2048-bit SSH-2 RSA keys`` for Linux and Windows instances. -- ``ED25519 keys`` for Linux instances (not supported for Windows). - -When you create a key pair using Amazon EC2: - -- The ``public key`` is stored in Amazon EC2. -- You store the ``private key`` securely on your local machine. - - -Steps to Create a Key Pair Using Amazon EC2 -^^^^^^^^^^^^^^ - -- Open the Amazon EC2 console https://console.aws.amazon.com/ec2/. - -- In the navigation pane, under ``Network & Security``, choose ``Key Pairs``. - -.. figure:: /_static/images/cloud-aws-keypair-01.png - -- Choose ``Create key pair`` and select ``AWS region`` at the top right corner of the windows where you plan to deploy the VyOS instance. - -.. figure:: /_static/images/cloud-aws-keypair-02.png - -- Configure Key Pair: -"""""""""" - - - **Name**: Enter a descriptive name for the key pair, e.g., ``vyos-keypair``. - - .. note:: The key name can include up to 255 ASCII characters. It cannot include leading or trailing spaces. - - - **Select Key Pair Type**: - - For **Linux instances**: Choose either **RSA** or **ED25519**. - - - For **Windows instances**: Choose **RSA**. - - .. note:: ED25519 keys are not supported for Windows instances. - - - **Private Key File Format**: - - **PEM**: Choose this format if using OpenSSH or other SSH clients (e.g., on Linux/macOS). - - **PPK**: Choose this format if using PuTTY on Windows. - -- **Optional**: Add tags to the key pair. Choose **Add tag** and provide the **key** and **value** for each tag. - -- Choose **Create key pair**. - -- The private key file will automatically download to your browser. - - The file name will match the name you provided (e.g., `vyos-keypair.pem`), with the extension determined by the format you chose. - -.. figure:: /_static/images/cloud-aws-keypair-03.png - -.. figure:: /_static/images/cloud-aws-keypair-04.png - - **Important Notes** - -- **Save the private key file securely**: - This is your **only chance** to download the private key. If you lose it, you cannot connect to your instance. - -- If you are using SSH on a **macOS or Linux computer**, set the correct permissions for the private key file: - -.. code-block:: none - - chmod 400 vyos-keypair.pem - -If permissions are not set to **400**, you will encounter an **"Unprotected private key file"** error when attempting to connect to the instance. - - **Example Usage for SSH** - -.. code-block:: none - - ssh -i vyos-keypair.pem vyos@<Public/Elastic IP> - -For more information, please visit the official AWS documentation: - -https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#having-ec2-create-your-key-pair - - -4. VyOS Subscription ------------ -- Go to the AWS Marketplace https://aws.amazon.com/marketplace and search for **VyOS**. -- Subscribe to the VyOS AMI. - -For more information, please visit: - -https://aws.amazon.com/marketplace/seller-profile?id=7636d180-1710-48bc-acd6-d323c4a0429f - - -Create required resources -======== - -Certain resources need to be created in the AWS infrastructure before creating a VyOS instance, such as a VPC, Subnets, Elastic IPs, Route Tables, Security Groups, and others. - -Step 1: Create Virtual Private Cloud (VPC) and Subnets ------------ - -1. Create a VPC -^^^^^^^^^^^^^^ - -To create a VPC for your AWS environment: - -- Go to the **Amazon VPC Console** at https://console.aws.amazon.com/vpc/. - -- In the navigation pane, choose **Your VPCs**. - -- Choose **Create VPC**. - -.. figure:: /_static/images/cloud-aws-vpc-01.png - -- **Configure VPC Settings**: - - **Name tag - optional**: Enter a descriptive name for your VPC, e.g., ``VyOS-VPC``. - - **IPv4 CIDR Block**: Enter ``10.0.0.0/16``. - -- Choose **Create VPC**. - -.. figure:: /_static/images/cloud-aws-vpc-02.png - -.. figure:: /_static/images/cloud-aws-vpc-03.png - -For more information, please visit the AWS documentation: - -https://docs.aws.amazon.com/vpc/latest/userguide/create-vpc.html - - -2. Create Subnets -^^^^^^^^^^^^^^ - -Subnets allow you to divide your VPC into smaller IP spaces. Follow these steps to create subnets for both **public** and **private** networks: - -- Go to the **Amazon VPC Console** at https://console.aws.amazon.com/vpc/. - -- In the navigation pane, choose **Subnets**. - -- Choose **Create Subnet**. - -.. figure:: /_static/images/cloud-aws-subnet-01.png - -- Configure Subnet Settings: -"""""""""" - - - **Public Subnet**: - - - **VPC**: Select ``VyOS-VPC``. - - - **Name Tag**: ``VyOS-Public-Subnet``. - - - **IPv4 CIDR Block**: ``10.0.1.0/24``. - - - **Availability Zone**: Select an AZ, e.g., ``us-east-1a``. - - - **Private Subnet**: - - - **VPC**: Select ``VyOS-VPC``. - - - **Name Tag**: ``VyOS-Private-Subnet``. - - - **IPv4 CIDR Block**: ``10.0.2.0/24``. - - - **Availability Zone**: Select an AZ, e.g., ``us-east-1a``. - - -- Choose **Create Subnet**. - -.. figure:: /_static/images/cloud-aws-subnet-02.png - -.. figure:: /_static/images/cloud-aws-subnet-03.png - -For additional information, please visit the AWS documentation: - -https://docs.aws.amazon.com/vpc/latest/userguide/create-subnets.html - -For additional details about IP addressing for your VPC and subnets, refer to the AWS documentation: - -https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html - - -Step 2: Create and Configure Security Groups ------------ - -1. Create Public Security Group -^^^^^^^^^^^^^^ - -The **Public Security Group** is used for **outbound connectivity**. All external resources, systems, or networks will connect via this security group. - -- Open the **Amazon EC2 Console** at https://console.aws.amazon.com/ec2/. - -- In the navigation pane, choose **Security Groups**. - -- Choose **Create Security Group**. - -.. figure:: /_static/images/cloud-aws-sg-01.png - -- **Configure the Security Group**: - - - **Name**: ``VyOS-Public-SG``. - - - **Description**: "Public security group for outbound connectivity" - - - **VPC**: Select the VPC in which your VyOS instance resides. - -- Inbound Rules: -"""""""""" - - - **SSH**: Port ``22``, Source ``0.0.0.0/0`` (Restrict to your IP for security). - - - **ICMP**: Allow for ping testing purposes. - - - **IPSec**: Allow port ``500`` (UDP) for ISAKMP (Phase 1 negotiation). - - - **NAT Traversal**: Allow port ``4500`` (UDP) for NAT-T support in IPsec. - - - **WireGuard**: Allow port ``51820`` (UDP). - - - **OpenVPN**: Allow port ``1194`` (UDP or TCP). - -.. figure:: /_static/images/cloud-aws-sg-02.png - -- (Optional) Add tags to identify the security group: - - **Key**: `Name`, **Value**: `VyOS-Public-SG`. - -- Choose **Create Security Group**. - -.. figure:: /_static/images/cloud-aws-sg-03.png - - -2. Create Private Security Group -^^^^^^^^^^^^^^ - -The **Private Security Group** is used for **internal connectivity** from internal or VPC-based resources. - -- Open the **Amazon EC2 Console**. - -- In the navigation pane, choose **Security Groups**. - -- Choose **Create Security Group**. - -- Configure the Security Group: -"""""""""" - - - **Name**: ``VyOS-Private-SG``. - - - **Description**: "Private security group for internal connectivity" - - - **VPC**: Select the VPC in which your VyOS instance resides. - -- Inbound Rules: -"""""""""" - - - Allow **All Traffic** (``0.0.0.0/0``) for internal connectivity between resources, VPCs, and other trusted networks. - -.. figure:: /_static/images/cloud-aws-sg-04.png - -- (Optional) Add tags to identify the security group: - - **Key**: ``Name``, **Value**: ``VyOS-Private-SG``. - -- Choose **Create Security Group**. - -.. figure:: /_static/images/cloud-aws-sg-05.png - -For detailed instructions on creating a security group, refer to the official AWS documentation: - -https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-security-group.html - -For more information, refer to the official AWS documentation: - -https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html - - -Step 3: Create ENIs (Elastic Network Interfaces) ------------ - -Network Interfaces (ENIs) are essential for connecting instances to subnets and managing network traffic. Follow the steps below to create **Public** and **Private** ENIs. - -- Open the **Amazon EC2 Console** at https://console.aws.amazon.com/ec2/. - -- In the navigation pane, choose **Network Interfaces**. - -- Choose **Create Network Interface**. - -- **Configure Network Interface Settings**: - -Public ENI -"""""""""" - - **Name**: ``VyOS-Public-ENI``. - - - **Description**: "Network Interface for Public Subnet." - - - **Subnet**: Select the ``VyOS-Public-Subnet`` you created earlier. - - - **Private IPv4 Address**: Choose **Auto-assign** to let AWS pick an IP address from the subnet. - - - **Security Group**: Select the ``VyOS-Public-SG``. - - - (Optional) Add tags to identify the ENIs: - **Key**: ``Name``, **Value**: ``VyOS-Public-ENI``. - - - Choose **Create Network Interface**. - - .. figure:: /_static/images/cloud-aws-eni-01.png - -Private ENI -"""""""""" - - **Name**: ``VyOS-Private-ENI``. - - - **Description**: "Network Interface for Private Subnet." - - - **Subnet**: Select the ``VyOS-Private-Subnet`` you created earlier. - - - **Private IPv4 Address**: Choose **Auto-assign** to let AWS pick an IP address from the subnet. - - - **Security Group**: Select the ``VyOS-Private-SG``. - - - (Optional) Add tags to identify the ENIs: - **Key**: ``Name``, **Value**: ``VyOS-Private-ENI``. - - - Choose **Create Network Interface**. - - .. figure:: /_static/images/cloud-aws-eni-02.png - -Step 4: Configure Internet Gateway ------------ - -An **Internet Gateway** allows communication between your VPC and the internet. Follow the steps below to create and attach an Internet Gateway to your VPC. - -1. Create an Internet Gateway -^^^^^^^^^^^^^^ - -- Open the **Amazon VPC Console** at https://console.aws.amazon.com/vpc/. - -- In the navigation pane, choose **Internet Gateways**. - -- Choose **Create Internet Gateway**. - -- **Configure Internet Gateway**: - - (Optional) **Name**: Enter a descriptive name, e.g., ``VyOS-IGW``. - -- (Optional) Add a tag to identify the Internet Gateway: - - **Key**: ``Name``, **Value**: ``VyOS-IGW``. - -- Choose **Create Internet Gateway**. - -.. figure:: /_static/images/cloud-aws-igw-01.png - - -2. Attach the Internet Gateway to Your VPC -^^^^^^^^^^^^^^ - -To enable your VPC to access the internet, attach the Internet Gateway to your VPC: - -- After creating the Internet Gateway, select it from the **Internet Gateways** list. - -- Choose **Actions > Attach to VPC**. - -- Select the VPC where you want to attach the Internet Gateway: - - Choose `VyOS-VPC` (the VPC you created earlier). - -- Choose **Attach Internet Gateway**. - -.. figure:: /_static/images/cloud-aws-igw-02.png - -For more details, refer to the official AWS documentation: - -https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html. - - -Step 5: Configure Route Tables ------------ - -Route tables define the paths for network traffic within your VPC. In this step, we will configure **Public** and **Private** route tables to control traffic flow for their respective subnets. - - -1. Create and Configure the Public Route Table -^^^^^^^^^^^^^^ - -- **Go to the Route Tables Section:** - - Open the **Amazon VPC Console** at https://console.aws.amazon.com/vpc/. - - In the left navigation pane, choose **Route Tables**. - -- **Create a New Route Table:** - - - In the **Route Tables** section, choose **Create Route Table**. - - - Configure the route table: - - - **Name**: ``Public RT``. - - - **VPC**: Select the ``VyOS-VPC``. - - - Click **Create Route Table**. - - .. figure:: /_static/images/cloud-aws-route-01.png - -- **Add a Route to the Internet Gateway:** - - - Go to the **Routes** tab and click **Edit Routes**. - - - Click **Add Route** and enter: - - - **Destination**: ``0.0.0.0/0`` (Default route to all IPs). - - - **Target**: Select the **Internet Gateway** (``VyOS-IGW``) you created earlier. - - - Click **Save Routes**. - - .. figure:: /_static/images/cloud-aws-route-02.png - -- **Associate the Public Subnet:** - - - Go to the **Subnet Associations** tab and click **Edit Subnet Associations**. - - - Select the **Public Subnet** (``VyOS-Public-Subnet``). - - - Click **Save associations**. - - .. figure:: /_static/images/cloud-aws-route-03.png - - -Step 6: Allocate and Attach Elastic IP (EIP) ------------ - -An **Elastic IP (EIP)** is a static, public IPv4 address designed for dynamic cloud computing. Elastic IP addresses can help maintain consistent connectivity to instances, even if they are stopped, rebooted, or replaced. - -- Elastic IP addresses are **public IPv4 addresses** and are reachable from the internet. -- They can be quickly remapped to different instances or network interfaces within your AWS account to mask failures. - -For more details, refer to the official AWS documentation: - -https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html. - - -Steps to Allocate and Attach Elastic IP -^^^^^^^^^^^^^^ - -1. Allocate Elastic IP -"""""""""" - -- Open the **Amazon EC2 Console** at https://console.aws.amazon.com/ec2/. - -- In the navigation pane, choose **Elastic IPs**. - -- Choose **Allocate Elastic IP address**. - -- **Elastic IP address settings**: - - For **Public IPv4 address pool**, select **Amazon's pool of IPv4 addresses**. - -- (Optional) Add a tag: - - **Key**: ``Name``, **Value**: ``VyOS-EIP``. - -- Choose **Allocate**. - -.. figure:: /_static/images/cloud-aws-eip-01.png - -2. Attach Elastic IP to Public ENI -"""""""""" - -- Go to **EC2 > Elastic IPs**. - -- Select the **Elastic IP** you just allocated. - -- Choose **Actions > Associate Elastic IP address**. - -- **Configure Association**: - - - **Resource type**: Choose **Network Interface**. - - - **Network Interface**: Select the **VyOS-Public-ENI** created earlier. - - - **Private IPv4 Address**: Ensure it is correctly selected. - -- (Optional) Select **Allow the Elastic IP address to be reassociated** if the EIP is already associated with another resource. - -- Choose **Associate**. - -.. figure:: /_static/images/cloud-aws-eip-02.png - -**Why Use Elastic IP?** - -- **Consistency**: The EIP remains static, even if the instance stops or is replaced. - -- **Failover**: If an instance fails, you can remap the EIP to a new instance to restore services quickly. - -- **DNS Integration**: You can point your domain to the Elastic IP for consistent public access. - -For additional details, refer to the AWS documentation: - -https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-eips.html - - -Launch VyOS Instance -======== - -Follow the detailed instructions below to launch a VyOS instance in your AWS environment with two ENIs (Public and Private). - -- Open the **Amazon EC2 Console** at https://console.aws.amazon.com/ec2/. - -- In the EC2 dashboard, choose **Launch Instance**. - -- **Configure Instance Details**: - - - **Name and Tags**: - - - Under **Name and tags**, enter a descriptive name for your instance, e.g., ``VyOS-Instance``. - - .. figure:: /_static/images/cloud-aws-vyos-01.png - - - **Application and OS Images (AMI)**: - - - Choose **Browse more AMIs**. - - - Go to the **AWS Marketplace** tab and search for **VyOS**. - - - Choose the VyOS AMI that matches your requirements and click **Select**. - - .. figure:: /_static/images/cloud-aws-vyos-02.png - - .. figure:: /_static/images/cloud-aws-vyos-03.png - - - **Instance Type**: - - Select the instance type that fits your workload. For example: - - - ``c5n.large`` (or larger recommended for VyOS). - - .. figure:: /_static/images/cloud-aws-vyos-04.png - - - **Key pair (login)**: - - - For **Key pair name**, select the key pair you created earlier (``vyos-keypair``). - - - If you do not have a key pair, create a new one and download the private key file. - - .. figure:: /_static/images/cloud-aws-vyos-05.png - - - **Network Settings**: - - - **VPC**: Select ``VyOS-VPC``. - - - **Subnet**: Select the **Public Subnet** (``VyOS-Public-Subnet``). - - - **Auto-assign Public IP**: **Disable**. - - - **Firewall (security groups)**: Select the **Select existing security group**. - - - **Common security groups**: Live empty (Do not select any security groups). - - .. figure:: /_static/images/cloud-aws-vyos-09.png - - - **Advanced network configuration** - - - **Network interface 1** select ``VyOS-Public-ENI`` - - .. figure:: /_static/images/cloud-aws-vyos-07.png - - - Click to the **Add network interface** button - - - **Network interface 2** select ``VyOS-Private-ENI`` - - .. figure:: /_static/images/cloud-aws-vyos-08.png - - - In **Subnet** deselect subnet - - .. figure:: /_static/images/cloud-aws-vyos-10.png - -- Review the instance configuration in the **Summary** panel and choose **Launch Instance**. - -- Wait until the instance status changes to **Running**. - -.. figure:: /_static/images/cloud-aws-vyos-11.png - - -Connect to the VyOS instance ------------ - - You can only connect to the VyOS instance via **SSH** protocol. Use the default username **vyos**, **Elastic IP** and **SSH Key Pair** to connect to the VyOS instance via SSH: - - .. code-block:: none - - ssh -i vyos-keypair.pem vyos@35.152.131.62 - - - - -Deployment of VyOS Instance and Required Resources via CloudFormation Template -======== - -These CloudFormation templates automate the deployment of a VyOS instance on AWS, configuring essential components such as: - -- VPC -- Public and private subnets -- Internet Gateway -- Route Tables -- Elastic IPs -- Security Groups - -You can download or clone these templates from the GitHub repository and use them in your environment: - -https://github.com/vyos/vyos-automation/tree/main/CloudFormation - - - -Deployment of VyOS Instance and Required Resources via Terraform -======== - -These Terraform projects automate the deployment of a VyOS instance on AWS, configuring essential components such as: - -- VPC -- Public and private subnets -- Internet Gateway -- Route Tables -- Elastic IPs -- Security Groups - -You can download or clone these templates from the GitHub repository and use them in your environment: - -https://github.com/vyos/vyos-automation/tree/main/Terraform/AWS/ - - -Amazon CloudWatch Agent Usage ------------------------------ - -To use Amazon CloudWatch Agent, configure it within the Amazon SSM Parameter Store. If you don't have a configuration yet, do :ref:`configuration_creation`. - -1. Create an :abbr:`IAM (Identity and Access Management)` role for the :abbr:`EC2 (Elastic Compute Cloud)` instance to access CloudWatch service, and name it CloudWatchAgentServerRole. The role should contain two default policies: CloudWatchAgentServerPolicy and AmazonSSMManagedInstanceCore. - -2. Attach the created role to your VyOS :abbr:`EC2 (Elastic Compute Cloud)` instance. - -3. Ensure that amazon-cloudwatch-agent package is installed. - - .. code-block:: none - - $ sudo apt list --installed | grep amazon-cloudwatch-agent - - .. note:: The amazon-cloudwatch-agent package is normally included in VyOS 1.3.3+ and 1.4+ - -3. Retrieve an existing CloudWatch Agent configuration from the :abbr:`SSM (Systems Manager)` Parameter Store. - - .. code-block:: none - - $ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:<your-configuration-name> - - This step also enables systemd service and runs it. - - .. note:: The VyOS platform-specific scripts feature is under development. Thus, this step should be repeated manually after changing system image (:doc:`/installation/update`) - -.. _configuration_creation: - -CloudWatch SSM Configuration creation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Creating the Amazon Cloudwatch Agent Configuration in Amazon :abbr:`SSM (Systems Manager)` Parameter Store. - -1. Create an :abbr:`IAM (Identity and Access Management)` role for your :abbr:`EC2 (Elastic Compute Cloud)` instance to access the CloudWatch service. Name it CloudWatchAgentAdminRole. The role should contain at two default policies: CloudWatchAgentAdminPolicy and AmazonSSMManagedInstanceCore. - - .. note:: CloudWatchAgentServerRole is too permissive and should be used for single configuration creation and deployment. That's why after completion of step #3 highly recommended to replace instance CloudWatchAgentAdminRole role with CloudWatchAgentServerRole. - -2. Run Cloudwatch configuration wizard. - - .. code-block:: none - - $ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard - -3. When prompted, answer "yes" to the question "Do you want to store the config in the SSM parameter store?". - -References ----------- -- https://console.aws.amazon.com/ -- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html -- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance-fleet.html |
