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

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