Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

阿里雲 ECS CentOS 啟用 IPv6 完整教學:Hurricane Electric Tunnel 實作

編輯:Linux 教學

前置條件

步驟 1:開啟系統 IPv6 支援

# 1. 修改網路設定
vim /etc/sysconfig/network
NETWORKING_IPV6=yes

# 2. 移除禁用模組設定 (如存在)
rm -f /etc/modprobe.d/disable_ipv6.conf

# 3. 載入模組並驗證
modprobe ipv6
lsmod | grep ipv6

步驟 2:建立 HE Tunnel

  1. 登入 tunnelbroker.net,點選 Create Regular Tunnel。
  2. IPv4 Endpoint 填入 ECS 公網 IP。
  3. 選擇最近的 Tunnel Server (如 Hong Kong, Tokyo)。
  4. 建立完成後,進入 Example Configurations,選擇 Linux-route2。
關鍵坑點:HE 提供的範例腳本中 local 參數需填入 ECS 內網 IP (私有 IP),而非公網 IP。因阿里雲 ECS 在 NAT 後方,公網 IP 不在本機介面上。

步驟 3:套用修正後的 Tunnel 腳本

# 假設內網 IP 為 172.16.100.50
# 從 Example Configurations 複製並修改 local 參數
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 216.218.221.42 local 172.16.100.50 ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:xxxx:xxxx::2/64 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -6 addr show dev he-ipv6

執行後 ifconfig 或 ip addr 應顯示 he-ipv6 介面與 IPv6 位址。

步驟 4:測試連通性

ping6 ipv6.google.com
ping6 2001:4860:4860::8888
# 或使用 curl -6 ipv6.test-ipv6.com

步驟 5:持久化 (重啟生效)

將上述指令寫入 /etc/rc.d/rc.local 並賦予執行權限:

chmod +x /etc/rc.d/rc.local
cat >> /etc/rc.d/rc.local <<'EOF'
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 216.218.221.42 local 172.16.100.50 ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:xxxx:xxxx::2/64 dev he-ipv6
ip route add ::/0 dev he-ipv6
EOF
補充發現:阿里雲 ECS CentOS 映像檔 /etc、/usr/bin 目錄預設無寫入權限 (不可修改系統檔),導致部分自動化腳本失效。/usr/local/bin 在 PATH 優先順序較高,可放置自訂腳本繞過限制。
Copyright © Windows教程網 All Rights Reserved