@xdev-asia/xdev-knowledge-mcp 1.0.54 → 1.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/01-bai-1-gioi-thieu-vyos-va-cai-dat.md +324 -0
  2. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/02-bai-2-cau-hinh-interface-va-ip-co-ban.md +324 -0
  3. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/03-bai-3-nat-source-nat-destination-nat-va-masquerade.md +321 -0
  4. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/04-bai-4-firewall-co-ban-rules-chains-va-groups.md +386 -0
  5. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/05-bai-5-zone-based-firewall.md +451 -0
  6. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/06-bai-6-dhcp-server-dns-forwarding-va-ntp.md +105 -0
  7. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/07-bai-7-vlans-bonding-va-bridge.md +94 -0
  8. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/08-bai-8-static-routing-va-policy-based-routing.md +83 -0
  9. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/09-bai-9-dynamic-routing-ospf.md +79 -0
  10. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/10-bai-10-dynamic-routing-bgp.md +82 -0
  11. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/11-bai-11-vpn-wireguard-va-openvpn.md +85 -0
  12. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/12-bai-12-vpn-ipsec-site-to-site.md +87 -0
  13. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/13-bai-13-high-availability-vrrp-va-conntrack-sync.md +61 -0
  14. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/14-bai-14-wan-load-balancing-qos-va-monitoring.md +62 -0
  15. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/chapters/01-vyos-tu-co-ban-den-nang-cao/lessons/15-bai-15-containers-automation-va-production-best-practices.md +80 -0
  16. package/content/series/devsecops/vyos-tu-co-ban-den-nang-cao/index.md +410 -0
  17. package/package.json +1 -1
@@ -0,0 +1,324 @@
1
+ ---
2
+ id: 019d65ef-d36f-773e-bf0a-9e2fc23d52ba
3
+ title: 'Bài 1: Giới thiệu VyOS và Cài đặt'
4
+ slug: bai-1-gioi-thieu-vyos-va-cai-dat
5
+ description: >-
6
+ Tìm hiểu VyOS là gì, lịch sử phát triển từ Vyatta, so sánh với pfSense/OPNsense/MikroTik,
7
+ kiến trúc hệ thống và hướng dẫn cài đặt trên KVM, VirtualBox, Proxmox, bare-metal.
8
+ duration_minutes: 150
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 1
12
+ section_title: "VyOS từ Cơ bản đến Nâng cao"
13
+ course:
14
+ id: 019d65ef-d36f-773e-bf0a-9e2efc5e19df
15
+ title: VyOS từ Cơ bản đến Nâng cao
16
+ slug: vyos-tu-co-ban-den-nang-cao
17
+ ---
18
+
19
+ <h2>VyOS là gì?</h2>
20
+
21
+ <p>VyOS là một <strong>hệ điều hành mạng mã nguồn mở</strong> (network operating system) dựa trên nền tảng Debian Linux. VyOS cung cấp đầy đủ tính năng routing, firewall, VPN và các dịch vụ mạng enterprise — tất cả được quản lý qua một CLI thống nhất tương tự như Juniper JunOS hoặc Cisco IOS.</p>
22
+
23
+ <p>Điểm đặc biệt của VyOS: bạn có thể triển khai nó như một <strong>software router</strong> trên máy ảo, cloud instance, container hoặc phần cứng vật lý — hoàn toàn miễn phí với bản rolling release.</p>
24
+
25
+ <h2>Lịch sử phát triển: Từ Vyatta đến VyOS</h2>
26
+
27
+ <p>Để hiểu VyOS, cần biết về Vyatta — dự án tiền thân:</p>
28
+
29
+ <ul>
30
+ <li><strong>2005</strong>: Vyatta Inc. ra mắt Vyatta Core — hệ điều hành router mã nguồn mở đầu tiên</li>
31
+ <li><strong>2012</strong>: Brocade Communications mua lại Vyatta, dần đóng mã nguồn</li>
32
+ <li><strong>2013</strong>: Cộng đồng fork Vyatta Core thành <strong>VyOS</strong>, tiếp tục phát triển mã nguồn mở</li>
33
+ <li><strong>2020+</strong>: VyOS chuyển sang mô hình rolling release (miễn phí) + LTS release (thương mại)</li>
34
+ <li><strong>2024–2025</strong>: VyOS 1.4 Sagitta (LTS), 1.5 Circinus (rolling) với nftables backend mới</li>
35
+ </ul>
36
+
37
+ <h2>So sánh VyOS với các giải pháp khác</h2>
38
+
39
+ <h3>VyOS vs pfSense / OPNsense</h3>
40
+
41
+ <p>pfSense và OPNsense là các firewall/router dựa trên FreeBSD với giao diện web. VyOS khác biệt ở chỗ:</p>
42
+
43
+ <ul>
44
+ <li><strong>CLI-first</strong>: VyOS được thiết kế cho quản trị qua dòng lệnh, hỗ trợ automation tốt hơn</li>
45
+ <li><strong>Routing nâng cao</strong>: VyOS tích hợp FRRouting — hỗ trợ BGP, OSPF, IS-IS, MPLS đầy đủ</li>
46
+ <li><strong>Linux-based</strong>: Dễ tích hợp với hệ sinh thái DevOps (Ansible, Terraform, containers)</li>
47
+ <li><strong>Scalability</strong>: Phù hợp cho cả homelab lẫn datacenter với hàng nghìn routes</li>
48
+ </ul>
49
+
50
+ <h3>VyOS vs MikroTik RouterOS</h3>
51
+
52
+ <ul>
53
+ <li>MikroTik: phần cứng chuyên dụng + phần mềm đóng, giá rẻ nhưng closed-source</li>
54
+ <li>VyOS: chạy trên bất kỳ phần cứng/cloud nào, mã nguồn mở, cộng đồng lớn</li>
55
+ <li>VyOS: CLI gần với Juniper JunOS — dễ chuyển đổi cho network engineers</li>
56
+ </ul>
57
+
58
+ <h2>Kiến trúc VyOS</h2>
59
+
60
+ <p>VyOS được xây dựng từ nhiều thành phần mã nguồn mở:</p>
61
+
62
+ <pre><code class="language-bash">+--------------------------------------------------+
63
+ | VyOS CLI |
64
+ | (configd / configuration tree) |
65
+ +--------------------------------------------------+
66
+ | FRRouting | nftables | StrongSwan |
67
+ | (BGP, OSPF, | (firewall, | (IPsec VPN) |
68
+ | IS-IS, RIP) | NAT, QoS) | |
69
+ +--------------------------------------------------+
70
+ | Debian Linux Kernel |
71
+ | (custom build, hardened) |
72
+ +--------------------------------------------------+
73
+ | Hardware / VM / Cloud Instance |
74
+ +--------------------------------------------------+</code></pre>
75
+
76
+ <p>Các thành phần chính:</p>
77
+
78
+ <ul>
79
+ <li><strong>Debian Linux</strong>: Nền tảng OS ổn định, bảo mật</li>
80
+ <li><strong>FRRouting (FRR)</strong>: Bộ routing protocols đầy đủ nhất trên Linux</li>
81
+ <li><strong>nftables</strong>: Thay thế iptables, xử lý firewall và NAT hiệu suất cao</li>
82
+ <li><strong>StrongSwan / WireGuard</strong>: IPsec và modern VPN</li>
83
+ <li><strong>configd</strong>: Configuration daemon — quản lý cây cấu hình (configuration tree)</li>
84
+ </ul>
85
+
86
+ <h2>Install Image vs Live Boot</h2>
87
+
88
+ <p>VyOS có hai chế độ hoạt động:</p>
89
+
90
+ <ul>
91
+ <li><strong>Live boot</strong>: Boot trực tiếp từ ISO, cấu hình chỉ tồn tại trong RAM. Mất khi reboot.</li>
92
+ <li><strong>Install image</strong>: Cài đặt lên disk, cấu hình được lưu vĩnh viễn. Đây là chế độ production.</li>
93
+ </ul>
94
+
95
+ <blockquote>
96
+ <p><strong>Lưu ý</strong>: Luôn dùng <code>install image</code> cho môi trường production. Live boot chỉ phù hợp để test nhanh.</p>
97
+ </blockquote>
98
+
99
+ <h2>Cài đặt VyOS</h2>
100
+
101
+ <h3>Tải VyOS ISO</h3>
102
+
103
+ <p>VyOS rolling release (miễn phí) có thể tải từ: <strong>https://vyos.net/get/</strong>. Hoặc bạn có thể tự build ISO từ source code.</p>
104
+
105
+ <h3>Cài đặt trên KVM/libvirt</h3>
106
+
107
+ <pre><code class="language-bash"># Tạo VM với virt-install
108
+ virt-install \
109
+ --name vyos-router \
110
+ --ram 1024 \
111
+ --vcpus 2 \
112
+ --disk path=/var/lib/libvirt/images/vyos.qcow2,size=8 \
113
+ --cdrom /path/to/vyos-rolling-latest.iso \
114
+ --network bridge=br0 \
115
+ --network bridge=br1 \
116
+ --os-variant debian11 \
117
+ --graphics vnc</code></pre>
118
+
119
+ <h3>Cài đặt trên VirtualBox</h3>
120
+
121
+ <p>Các bước cơ bản cho VirtualBox:</p>
122
+
123
+ <ul>
124
+ <li>Tạo VM loại <strong>Linux / Debian 64-bit</strong>, RAM 1GB, disk 8GB</li>
125
+ <li>Thêm 2 network adapters: Adapter 1 = NAT hoặc Bridged (WAN), Adapter 2 = Internal Network (LAN)</li>
126
+ <li>Mount ISO và boot</li>
127
+ </ul>
128
+
129
+ <h3>Cài đặt trên Proxmox</h3>
130
+
131
+ <pre><code class="language-bash"># Upload ISO lên Proxmox storage
132
+ # Tạo VM:
133
+ # - OS Type: Linux, Version: 6.x - 2.6 Kernel
134
+ # - CPU: 2 cores, RAM: 1024MB
135
+ # - Disk: 8GB (VirtIO)
136
+ # - Network: 2x VirtIO NICs (vmbr0 cho WAN, vmbr1 cho LAN)
137
+ # Boot từ ISO</code></pre>
138
+
139
+ <h3>Cài đặt trên bare-metal</h3>
140
+
141
+ <p>VyOS hỗ trợ hầu hết phần cứng x86_64 với NIC Intel/Broadcom. Burn ISO ra USB bằng <code>dd</code> hoặc Balena Etcher, boot và cài đặt bình thường.</p>
142
+
143
+ <h3>Quá trình Install Image</h3>
144
+
145
+ <p>Sau khi boot từ ISO, login với user <code>vyos</code> / password <code>vyos</code>, rồi chạy:</p>
146
+
147
+ <pre><code class="language-bash">vyos@vyos:~$ install image
148
+ Welcome to VyOS installation!
149
+ # Chọn disk để cài đặt
150
+ Would you like to continue? (y/N): y
151
+ Partition (Auto/Parted/Skip) [Auto]: Auto
152
+ Install the image on? [sda]: sda
153
+ How big of a root partition should I create? (GB) [8]: 8
154
+ What would you like to name this image? [1.5-rolling-...]: Enter
155
+ Which one should I copy to sda? [/config/config.boot]: Enter
156
+ Enter password for user 'vyos': ********
157
+ # Đợi cài đặt hoàn tất
158
+ reboot</code></pre>
159
+
160
+ <h2>CLI cơ bản của VyOS</h2>
161
+
162
+ <p>VyOS có hai chế độ CLI:</p>
163
+
164
+ <ul>
165
+ <li><strong>Operational mode</strong>: Xem trạng thái, chạy lệnh show, ping, traceroute (prompt: <code>$</code>)</li>
166
+ <li><strong>Configuration mode</strong>: Thay đổi cấu hình (prompt: <code>#</code>)</li>
167
+ </ul>
168
+
169
+ <h3>Các lệnh quan trọng nhất</h3>
170
+
171
+ <pre><code class="language-bash"># Vào configuration mode
172
+ vyos@vyos:~$ configure
173
+
174
+ # Xem cấu hình hiện tại
175
+ vyos@vyos# show
176
+
177
+ # Thêm cấu hình
178
+ vyos@vyos# set interfaces ethernet eth0 address 192.168.1.1/24
179
+
180
+ # So sánh thay đổi chưa commit
181
+ vyos@vyos# compare
182
+
183
+ # Áp dụng cấu hình (chưa lưu vĩnh viễn)
184
+ vyos@vyos# commit
185
+
186
+ # Lưu cấu hình vĩnh viễn (survive reboot)
187
+ vyos@vyos# save
188
+
189
+ # Hủy thay đổi chưa commit
190
+ vyos@vyos# discard
191
+
192
+ # Xóa một cấu hình
193
+ vyos@vyos# delete interfaces ethernet eth0 address 192.168.1.1/24
194
+
195
+ # Thoát configuration mode
196
+ vyos@vyos# exit</code></pre>
197
+
198
+ <h3>Configuration Tree</h3>
199
+
200
+ <p>Toàn bộ cấu hình VyOS được tổ chức dạng <strong>cây phân cấp</strong> (hierarchical tree). Mỗi node trong cây đại diện cho một tính năng:</p>
201
+
202
+ <pre><code class="language-bash">vyos@vyos# show
203
+ interfaces {
204
+ ethernet eth0 {
205
+ address 192.168.1.1/24
206
+ description "LAN"
207
+ }
208
+ ethernet eth1 {
209
+ address dhcp
210
+ description "WAN"
211
+ }
212
+ }
213
+ system {
214
+ host-name vyos-router
215
+ login {
216
+ user vyos {
217
+ authentication {
218
+ encrypted-password "..."
219
+ }
220
+ }
221
+ }
222
+ }
223
+ service {
224
+ ssh {
225
+ port 22
226
+ }
227
+ }</code></pre>
228
+
229
+ <p>Bạn có thể <strong>navigate</strong> vào từng nhánh để xem chi tiết:</p>
230
+
231
+ <pre><code class="language-bash"># Xem chỉ phần interfaces
232
+ vyos@vyos# show interfaces
233
+
234
+ # Xem chỉ interface eth0
235
+ vyos@vyos# show interfaces ethernet eth0</code></pre>
236
+
237
+ <h2>Tab Completion và Help</h2>
238
+
239
+ <p>CLI của VyOS hỗ trợ <strong>tab completion</strong> cực kỳ mạnh — giúp bạn không cần nhớ hết tất cả commands:</p>
240
+
241
+ <pre><code class="language-bash"># Nhấn Tab để xem các tùy chọn
242
+ vyos@vyos# set interfaces [Tab]
243
+ Possible completions:
244
+ bonding Bonding interface
245
+ bridge Bridge interface
246
+ dummy Dummy interface
247
+ ethernet Ethernet interface
248
+ loopback Loopback interface
249
+ openvpn OpenVPN interface
250
+ tunnel Tunnel interface
251
+ vxlan VXLAN interface
252
+ wireguard WireGuard interface
253
+ wireless Wireless interface
254
+
255
+ # Dùng ? để xem help
256
+ vyos@vyos# set interfaces ethernet eth0 ?</code></pre>
257
+
258
+ <h2>Lab thực hành: Cài đặt VyOS trên VirtualBox</h2>
259
+
260
+ <p>Thực hiện các bước sau để có một VyOS router hoạt động:</p>
261
+
262
+ <h3>Bước 1: Tạo VM</h3>
263
+ <ul>
264
+ <li>Mở VirtualBox, tạo VM mới: Name = <code>vyos-lab</code>, Type = Linux, Version = Debian 64-bit</li>
265
+ <li>RAM: 1024 MB, Disk: 8 GB (VDI, dynamically allocated)</li>
266
+ <li>Adapter 1: NAT (sẽ là WAN), Adapter 2: Internal Network tên <code>lab-lan</code></li>
267
+ </ul>
268
+
269
+ <h3>Bước 2: Boot và Install</h3>
270
+ <pre><code class="language-bash"># Boot từ ISO, login: vyos / vyos
271
+ vyos@vyos:~$ install image
272
+ # Chọn tất cả mặc định, đặt password mới
273
+ # Sau khi xong: reboot
274
+ # Tháo ISO khỏi VM</code></pre>
275
+
276
+ <h3>Bước 3: Cấu hình cơ bản</h3>
277
+ <pre><code class="language-bash"># Login lại sau reboot
278
+ vyos@vyos:~$ configure
279
+
280
+ # Đặt hostname
281
+ set system host-name vyos-lab
282
+
283
+ # Cấu hình WAN (DHCP từ NAT)
284
+ set interfaces ethernet eth0 description 'WAN'
285
+ set interfaces ethernet eth0 address dhcp
286
+
287
+ # Cấu hình LAN
288
+ set interfaces ethernet eth1 description 'LAN'
289
+ set interfaces ethernet eth1 address 192.168.100.1/24
290
+
291
+ # Bật SSH
292
+ set service ssh port 22
293
+
294
+ # Commit và save
295
+ commit
296
+ save</code></pre>
297
+
298
+ <h3>Bước 4: Kiểm tra</h3>
299
+ <pre><code class="language-bash"># Thoát configure mode
300
+ exit
301
+
302
+ # Kiểm tra interfaces
303
+ show interfaces
304
+
305
+ # Kiểm tra kết nối WAN
306
+ ping 8.8.8.8
307
+
308
+ # Xem routing table
309
+ show ip route</code></pre>
310
+
311
+ <h2>Tổng kết</h2>
312
+
313
+ <p>Trong bài học này, bạn đã nắm được:</p>
314
+
315
+ <ul>
316
+ <li>VyOS là hệ điều hành mạng mã nguồn mở, phát triển từ Vyatta, chạy trên Debian Linux</li>
317
+ <li>Kiến trúc VyOS gồm FRRouting (routing), nftables (firewall/NAT), StrongSwan (VPN)</li>
318
+ <li>Sự khác biệt giữa VyOS với pfSense, OPNsense và MikroTik</li>
319
+ <li>Cách cài đặt VyOS trên các nền tảng ảo hóa (KVM, VirtualBox, Proxmox) và bare-metal</li>
320
+ <li>CLI cơ bản: <code>configure</code>, <code>set</code>, <code>commit</code>, <code>save</code>, <code>compare</code>, <code>show</code></li>
321
+ <li>Khái niệm configuration tree — nền tảng để hiểu toàn bộ hệ thống VyOS</li>
322
+ </ul>
323
+
324
+ <p>Bài tiếp theo sẽ đi sâu vào cấu hình interfaces, IP addressing và các thiết lập hệ thống cơ bản.</p>
@@ -0,0 +1,324 @@
1
+ ---
2
+ id: 019d65ef-d36f-773e-bf0a-9e30df834552
3
+ title: 'Bài 2: Cấu hình Interface và IP cơ bản'
4
+ slug: bai-2-cau-hinh-interface-va-ip-co-ban
5
+ description: >-
6
+ Hướng dẫn cấu hình interfaces ethernet, IP tĩnh, DHCP client, quản lý users,
7
+ hostname, timezone, NTP, DNS và backup/restore config trên VyOS.
8
+ duration_minutes: 120
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 2
12
+ section_title: "VyOS từ Cơ bản đến Nâng cao"
13
+ course:
14
+ id: 019d65ef-d36f-773e-bf0a-9e2efc5e19df
15
+ title: VyOS từ Cơ bản đến Nâng cao
16
+ slug: vyos-tu-co-ban-den-nang-cao
17
+ ---
18
+
19
+ <h2>Cấu hình Ethernet Interfaces</h2>
20
+
21
+ <p>Trong VyOS, mỗi interface vật lý hoặc ảo được quản lý qua configuration tree tại node <code>interfaces</code>. Ethernet interface thường có tên <code>eth0</code>, <code>eth1</code>,... tương ứng với thứ tự NIC được kernel detect.</p>
22
+
23
+ <h3>Gán IP tĩnh cho interface</h3>
24
+
25
+ <pre><code class="language-bash">configure
26
+
27
+ # Gán IP cho eth0 (WAN)
28
+ set interfaces ethernet eth0 address 203.0.113.10/24
29
+ set interfaces ethernet eth0 description 'WAN - Internet'
30
+
31
+ # Gán IP cho eth1 (LAN)
32
+ set interfaces ethernet eth1 address 192.168.1.1/24
33
+ set interfaces ethernet eth1 description 'LAN - Internal'
34
+
35
+ # Xem thay đổi trước khi commit
36
+ compare
37
+
38
+ commit
39
+ save</code></pre>
40
+
41
+ <p>Một interface có thể có <strong>nhiều địa chỉ IP</strong> (secondary addresses):</p>
42
+
43
+ <pre><code class="language-bash">set interfaces ethernet eth1 address 192.168.1.1/24
44
+ set interfaces ethernet eth1 address 10.0.0.1/24</code></pre>
45
+
46
+ <h3>Cấu hình DHCP Client</h3>
47
+
48
+ <p>Khi interface WAN nhận IP từ ISP qua DHCP:</p>
49
+
50
+ <pre><code class="language-bash">set interfaces ethernet eth0 address dhcp
51
+
52
+ # Xem IP được cấp
53
+ show interfaces ethernet eth0</code></pre>
54
+
55
+ <h3>Disable/Enable Interface</h3>
56
+
57
+ <pre><code class="language-bash"># Disable interface
58
+ set interfaces ethernet eth2 disable
59
+
60
+ # Enable lại (xóa disable flag)
61
+ delete interfaces ethernet eth2 disable
62
+
63
+ commit</code></pre>
64
+
65
+ <h3>Xem trạng thái interfaces</h3>
66
+
67
+ <pre><code class="language-bash"># Operational mode
68
+ show interfaces
69
+
70
+ # Output mẫu:
71
+ # Codes: S - State, L - Link, u - Up, D - Down
72
+ # Interface IP Address S/L Description
73
+ # --------- ---------- --- -----------
74
+ # eth0 203.0.113.10/24 u/u WAN - Internet
75
+ # eth1 192.168.1.1/24 u/u LAN - Internal
76
+ # lo 127.0.0.1/8 u/u
77
+
78
+ # Xem chi tiết một interface
79
+ show interfaces ethernet eth0 brief</code></pre>
80
+
81
+ <h2>Quản lý Users và Authentication</h2>
82
+
83
+ <h3>Tạo user mới</h3>
84
+
85
+ <pre><code class="language-bash">configure
86
+
87
+ # Tạo user admin với plaintext password (VyOS sẽ tự hash)
88
+ set system login user admin authentication plaintext-password 'MyStr0ngP@ss!'
89
+ set system login user admin level admin
90
+
91
+ # Hoặc dùng encrypted password (đã hash sẵn)
92
+ # Tạo hash: openssl passwd -6 'MyStr0ngP@ss!'
93
+ set system login user admin authentication encrypted-password '$6$rounds=...'
94
+
95
+ commit
96
+ save</code></pre>
97
+
98
+ <blockquote>
99
+ <p><strong>Bảo mật</strong>: Sau khi commit, VyOS tự động chuyển plaintext-password thành encrypted-password trong config. Plaintext password không được lưu trữ.</p>
100
+ </blockquote>
101
+
102
+ <h3>Cấu hình SSH Key Authentication</h3>
103
+
104
+ <pre><code class="language-bash"># Thêm SSH public key cho user admin
105
+ set system login user admin authentication public-keys mykey@workstation type ssh-rsa
106
+ set system login user admin authentication public-keys mykey@workstation key 'AAAAB3NzaC1yc2EAAAA...'
107
+
108
+ commit
109
+ save</code></pre>
110
+
111
+ <h3>Xóa user</h3>
112
+
113
+ <pre><code class="language-bash">delete system login user old-admin
114
+ commit
115
+ save</code></pre>
116
+
117
+ <h2>Cấu hình System cơ bản</h2>
118
+
119
+ <h3>Hostname</h3>
120
+
121
+ <pre><code class="language-bash">configure
122
+ set system host-name vyos-gw01
123
+ set system domain-name lab.local
124
+ commit
125
+ save</code></pre>
126
+
127
+ <h3>Timezone</h3>
128
+
129
+ <pre><code class="language-bash"># Xem danh sách timezone
130
+ # Nhấn Tab sau 'set system time-zone'
131
+ set system time-zone Asia/Ho_Chi_Minh
132
+ commit
133
+ save</code></pre>
134
+
135
+ <h3>NTP — Đồng bộ thời gian</h3>
136
+
137
+ <pre><code class="language-bash"># Cấu hình NTP servers
138
+ set service ntp server pool.ntp.org
139
+ set service ntp server time.google.com
140
+
141
+ # Hoặc cấu hình chi tiết
142
+ set service ntp server 0.pool.ntp.org prefer
143
+ set service ntp server 1.pool.ntp.org
144
+
145
+ # Xem trạng thái NTP
146
+ show ntp
147
+
148
+ commit
149
+ save</code></pre>
150
+
151
+ <h3>System DNS (Name Server)</h3>
152
+
153
+ <p>Cấu hình DNS servers mà VyOS sẽ sử dụng để resolve tên miền:</p>
154
+
155
+ <pre><code class="language-bash"># DNS cho chính router
156
+ set system name-server 8.8.8.8
157
+ set system name-server 1.1.1.1
158
+
159
+ commit
160
+ save
161
+
162
+ # Kiểm tra
163
+ ping google.com</code></pre>
164
+
165
+ <h2>Bật SSH Service</h2>
166
+
167
+ <pre><code class="language-bash">configure
168
+
169
+ # Bật SSH trên port mặc định 22
170
+ set service ssh port 22
171
+
172
+ # Hoặc đổi port cho bảo mật
173
+ set service ssh port 2222
174
+
175
+ # Disable password login (chỉ cho key-based)
176
+ set service ssh disable-password-authentication
177
+
178
+ # Giới hạn SSH chỉ listen trên LAN interface
179
+ set service ssh listen-address 192.168.1.1
180
+
181
+ commit
182
+ save</code></pre>
183
+
184
+ <h2>Default Gateway và Static Routes</h2>
185
+
186
+ <pre><code class="language-bash">configure
187
+
188
+ # Đặt default gateway (cho WAN IP tĩnh)
189
+ set protocols static route 0.0.0.0/0 next-hop 203.0.113.1
190
+
191
+ # Thêm static route cho mạng khác
192
+ set protocols static route 10.10.0.0/16 next-hop 192.168.1.254
193
+
194
+ # Xem routing table
195
+ show ip route
196
+
197
+ commit
198
+ save</code></pre>
199
+
200
+ <h2>Backup và Restore Config</h2>
201
+
202
+ <h3>Save / Load config</h3>
203
+
204
+ <pre><code class="language-bash"># Save config hiện tại (mặc định lưu vào /config/config.boot)
205
+ save
206
+
207
+ # Save ra file cụ thể
208
+ save /config/backup-2026-04-07.config
209
+
210
+ # Load config từ file
211
+ load /config/backup-2026-04-07.config
212
+ # Xem thay đổi
213
+ compare
214
+ # Nếu OK thì commit
215
+ commit
216
+ save</code></pre>
217
+
218
+ <h3>Save config ra remote server</h3>
219
+
220
+ <pre><code class="language-bash"># Save qua SCP
221
+ save scp://user@backup-server/path/to/vyos-backup.config
222
+
223
+ # Save qua TFTP
224
+ save tftp://tftp-server/vyos-backup.config
225
+
226
+ # Save qua FTP
227
+ save ftp://user:password@ftp-server/vyos-backup.config</code></pre>
228
+
229
+ <h3>Rollback config</h3>
230
+
231
+ <p>VyOS lưu lịch sử các lần commit. Bạn có thể rollback:</p>
232
+
233
+ <pre><code class="language-bash"># Xem lịch sử commit
234
+ show system commit
235
+
236
+ # Rollback về revision trước
237
+ rollback 1
238
+ compare
239
+ commit
240
+ save</code></pre>
241
+
242
+ <h2>Lab thực hành: Setup Router 2 Interfaces WAN + LAN</h2>
243
+
244
+ <p>Topology:</p>
245
+
246
+ <pre><code class="language-bash">Internet --- [eth0 WAN: DHCP] VyOS Router [eth1 LAN: 192.168.100.1/24] --- LAN Clients</code></pre>
247
+
248
+ <h3>Bước 1: Cấu hình interfaces</h3>
249
+
250
+ <pre><code class="language-bash">configure
251
+
252
+ # WAN - nhận IP từ ISP
253
+ set interfaces ethernet eth0 description 'WAN'
254
+ set interfaces ethernet eth0 address dhcp
255
+
256
+ # LAN - IP tĩnh
257
+ set interfaces ethernet eth1 description 'LAN'
258
+ set interfaces ethernet eth1 address 192.168.100.1/24
259
+
260
+ commit</code></pre>
261
+
262
+ <h3>Bước 2: Cấu hình system</h3>
263
+
264
+ <pre><code class="language-bash"># Hostname
265
+ set system host-name vyos-home
266
+
267
+ # DNS
268
+ set system name-server 8.8.8.8
269
+ set system name-server 1.1.1.1
270
+
271
+ # Timezone
272
+ set system time-zone Asia/Ho_Chi_Minh
273
+
274
+ # NTP
275
+ set service ntp server pool.ntp.org
276
+
277
+ # SSH
278
+ set service ssh port 22
279
+
280
+ commit</code></pre>
281
+
282
+ <h3>Bước 3: Tạo user admin riêng</h3>
283
+
284
+ <pre><code class="language-bash"># Tạo admin user
285
+ set system login user admin authentication plaintext-password 'SecureP@ss2026!'
286
+ set system login user admin level admin
287
+
288
+ # Xóa default password của user vyos (đổi password)
289
+ set system login user vyos authentication plaintext-password 'NewVyOSP@ss!'
290
+
291
+ commit
292
+ save</code></pre>
293
+
294
+ <h3>Bước 4: Kiểm tra</h3>
295
+
296
+ <pre><code class="language-bash">exit
297
+
298
+ # Kiểm tra interfaces
299
+ show interfaces
300
+
301
+ # Kiểm tra DNS resolution
302
+ ping google.com
303
+
304
+ # Kiểm tra NTP
305
+ show ntp
306
+
307
+ # Kiểm tra config đã save
308
+ show configuration</code></pre>
309
+
310
+ <h2>Tổng kết</h2>
311
+
312
+ <p>Trong bài này, bạn đã học được:</p>
313
+
314
+ <ul>
315
+ <li>Cách cấu hình ethernet interfaces: IP tĩnh, DHCP client, multiple addresses</li>
316
+ <li>Quản lý users: tạo, xóa, đặt password, thêm SSH keys</li>
317
+ <li>Thiết lập system basics: hostname, timezone, NTP, DNS</li>
318
+ <li>Bật và bảo mật SSH service</li>
319
+ <li>Cấu hình default gateway và static routes</li>
320
+ <li>Backup, restore và rollback configuration</li>
321
+ <li>Lab thực hành: Setup router 2 interfaces WAN + LAN hoàn chỉnh</li>
322
+ </ul>
323
+
324
+ <p>Bài tiếp theo sẽ hướng dẫn cấu hình NAT — cho phép LAN clients truy cập Internet qua VyOS router.</p>