Bước 1: Cài VLAN và tạo rule routing
| apt install vlan modprobe 8021q |
Bước 2: Cấu hình Netplan:
– Chỉnh sửa file /etc/netplan/01-netcfg.yaml như sau:
| network: version: 2 ethernets: enp24s0f0np0: dhcp4: false dhcp6: false vlans: vlan211: id: 211 link: enp24s0f0np0 addresses: – 163.61.111.113/24 – 163.61.111.20/24 ….. gateway4: 163.61.111.1 routes: – to: 0.0.0.0/0 via: 163.61.111.1 table: 101 routing-policy: – from: 163.61.111.113 table: 101 – from: 163.61.111.20 table: 101 ….. nameservers: addresses: – 1.1.1.1 – 8.8.8.8 vlan77: id: 77 link: enp24s0f0np0 addresses: – 103.180.138.10/24 – 103.180.138.16/24 ….. gateway4: 163.61.111.1 routes: – to: 0.0.0.0/0 via: 163.61.111.1 table: 101 routing-policy: – from: 103.180.138.10 table: 102 – from: 103.180.138.16 table: 102 …. nameservers: addresses: – 1.1.1.1 – 8.8.8.8 |
Bước 3: Khai báo bảng định tuyến bổ sung
– Chỉnh file /etc/iproute2/rt_tables để thêm:
| echo “101 vlan211” | sudo tee -a /etc/iproute2/rt_tables echo “102 vlan77” | sudo tee -a /etc/iproute2/rt_tables …. |
Bước 4: Áp dụng cấu hình
| netplan apply |
Bước 5: Thay đổi cấu hình port mode:
– Nếu cấu hình trên server, thì vào Switch của đổi port của server từ access -> trunk
– Nếu cấu hình trên VPS, đổi card mạng sang port group vlan trunk (kiểm tra VLAN ID đã có trong port group vlan trunk chưa)
Bước 6: Kiểm tra
| ip a # Kiểm tra IP các interface ip r # Kiểm tra định tuyến mặc định ip rule # Kiểm tra policy-based routing ping -I 163.61.111.113 8.8.8.8 ping -I 103.180.138.10 8.8.8.8 |
Leave A Comment?