summaryrefslogtreecommitdiff
path: root/docs/ch04-configuration-overview.rst
blob: 549513643d062e0ab660dde58707d948cbb0f2d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
Configuration Overview
======================

VyOS makes use of a unified configuration file for all system configuration:
`config.boot`. This allows for easy template creation, backup, and replication
of system configuration.

The current configuration can be viewed using the show configuration command.

.. code-block:: sh

  vyos@vyos:~$ show configuration
  interfaces {
      ethernet eth0 {
          address dhcp
          hw-id 00:0c:29:44:3b:0f
      }
      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
              }
          }
      }
  }
  vyos@vyos:~$

Because configuration changes are made using `set` and `delete` commands, the
commands to generate the active configuration can also be displayed using the
`show configuration commands` command.

.. code-block:: sh

  vyos@vyos:~$ show configuration commands
  set interfaces ethernet eth0 address 'dhcp'
  set interfaces ethernet eth0 hw-id '00:0c:29: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 '<removed>'
  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'
  vyos@vyos:~$

Configuration changes made do not take effect until committed using the commit
command in configuration mode.

.. code-block:: sh

  vyos@vyos# commit
  [edit]
  vyos@vyos# exit
  Warning: configuration changes have not been saved.
  vyos@vyos:~$

In order to preserve configuration changes upon reboot, the configuration must
also be saved once applied. This is done using the save command in
configuration mode.

.. code-block:: sh

  vyos@vyos# save
  Saving configuration to '/config/config.boot'...
  Done
  [edit]
  vyos@vyos#

The show command within configuration mode will show the current configuration
indicating line changes with a + for additions and a - for deletions.

.. code-block:: sh

  vyos@vyos:~$ configure
  [edit]
  vyos@vyos# show interfaces
    ethernet eth0 {
        address dhcp
        hw-id 00:0c:29:44:3b:0f
    }
    loopback lo {
    }
  [edit]
  vyos@vyos# set interfaces ethernet eth0 description 'OUTSIDE'
  [edit]
  vyos@vyos# show interfaces
   ethernet eth0 {
       address dhcp
  +    description OUTSIDE
       hw-id 00:0c:29:44:3b:0f
   }
   loopback lo {
   }
  [edit]
  vyos@vyos#

Configuration mode can not be exited while uncommitted changes exist. To exit
configuration mode without applying changes, the exit discard command can be
used.

.. code-block:: sh

  vyos@vyos# exit
  Cannot exit: configuration modified.
  Use 'exit discard' to discard the changes and exit.
  [edit]
  vyos@vyos# exit discard
  exit
  vyos@vyos:~$

VyOS also maintains backups of previous configurations. To compare
configuration revisions in configuration mode, use the compare command:

.. code-block:: sh

  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

  [edit]
  vyos@vyos#

You can rollback configuration using the rollback command, however this
command will currently trigger a system reboot.

.. code-block:: sh

  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!
  [edit]
  vyos@vyos#

VyOS also supports saving and loading configuration remotely using SCP, FTP,
or TFTP.

.. code-block:: sh

  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