Like Share Discussion Bookmark Smile

J.J. Huang   2025-11-19   Linode   瀏覽次數:次   DMCA.com Protection Status

Cloud | Linode VPS 網卡筆記:未先設定 VLAN 的處理方式

💬 前言

這篇文章是一份技術筆記,紀錄在 Linode VPS 建立時未先設定 VLAN,後續需要手動配置 eth1 網卡 的處理方式。
內容僅涵蓋核心流程與設定檔,方便自己與後續需要的人快速參考與重現。

📝 筆記

Linode eth1 網卡設定(使用 systemd-networkd)

本文件說明如何在 Linode 上使用 systemd-networkd 持久化設定 eth1 的 IP 位址,並重新啟動網路服務。

為什麼需要手動設定 eth1?

當你在 Linode 建立節點(Node)時,如果當時沒有設定 VLAN,系統就不會自動建立 eth1 的網路設定。
即使你後來在 Linode 控制台新增了 VLAN,若你已關閉「Auto-configure networking」,Linode 就不會再自動幫你設定 eth1 的 IP 位址與網路參數。

因此,你需要手動建立 eth1 的設定檔,讓它在每次開機時自動啟用並正確取得 IP。


新建/編輯 eth1 的網路設定檔

使用編輯器開啟設定檔:

1
vim /etc/systemd/network/05-eth1.network

填入以下內容(你已經關閉 Linode 的 Auto-configure networking,因此這份檔案不會被覆蓋):

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
# Generated by Linode Network Helper
# Thu Nov 6 12:07:06 2025 UTC
#
# This file is automatically generated on each boot with your Linode's
# current network configuration. If you need to modify this file, please
# first disable the 'Auto-configure networking' setting within your Linode's
# configuration profile:
# - https://cloud.linode.com/linodes/86670316/configurations
#
# For more information on Network Helper:
# - https://www.linode.com/docs/guides/network-helper/
#
# A backup of the previous config is at /etc/systemd/network/.05-eth1.network.linode-last
# A backup of the original config is at /etc/systemd/network/.05-eth1.network.linode-orig
#
# /etc/systemd/network/05-eth1.network

[Match]
Name=eth1

[Network]
DHCP=no

Domains=members.linode.com
IPv6PrivacyExtensions=false

Address=192.168.100.20/24

⚠️ 注意 192.168.100.20/24 ,根據這台服務要設定的靜態 IP 做配置。

重新啟動 systemd-networkd 套用設定

1
systemctl restart systemd-networkd

驗證設定是否生效

執行以下指令確認 eth1 是否正確取得 IP:

1
ip addr show eth1
1
2
3
4
5
6
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 90:de:01:68:e1:4d brd ff:ff:ff:ff:ff:ff
inet 192.168.100.20/24 brd 192.168.100.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::92de:1ff:fe68:e14d/64 scope link
valid_lft forever preferred_lft forever

👌 結語

本文主要紀錄了在 Linode VPS 上,因為建立時未先設定 VLAN,後續必須透過 systemd-networkd 手動配置 eth1 網卡的流程。
這不是完整的教學,而是一份技術筆記,重點在於 核心設定檔與驗證方法,方便未來快速重現。

⚠️ 提醒

  • 請依照自身需求調整 IP 與 VLAN 網段。
  • 建議搭配 Linode 官方文件,確保設定符合最新版本與最佳實踐。