mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-09-08 15:34:15 +08:00
update
This commit is contained in:
parent
80b0fcdf64
commit
7f506c30fd
6 changed files with 14 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# from
|
# from
|
||||||
# https://github.com/spiritLHLS/pve
|
# https://github.com/spiritLHLS/pve
|
||||||
# 2023.08.21
|
# 2023.08.22
|
||||||
|
|
||||||
|
|
||||||
########## 预设部分输出和部分中间变量
|
########## 预设部分输出和部分中间变量
|
||||||
|
@ -225,7 +225,7 @@ if [ "$ipv6_prefixlen" -le 64 ]; then
|
||||||
cat << EOF | sudo tee -a "$interfaces_file"
|
cat << EOF | sudo tee -a "$interfaces_file"
|
||||||
auto vmbr2
|
auto vmbr2
|
||||||
iface vmbr2 inet6 static
|
iface vmbr2 inet6 static
|
||||||
address ${ipv6_address_without_last_segment}2/${ipv6_prefixlen}
|
address ${ipv6_address_without_last_segment}1/${ipv6_prefixlen}
|
||||||
bridge_ports none
|
bridge_ports none
|
||||||
bridge_stp off
|
bridge_stp off
|
||||||
bridge_fd 0
|
bridge_fd 0
|
||||||
|
|
|
@ -245,7 +245,7 @@ pct set $CTID --hostname $CTID
|
||||||
if [ "$independent_ipv6" == "Y" ]; then
|
if [ "$independent_ipv6" == "Y" ]; then
|
||||||
if [ "$ipv6_prefixlen" -le 64 ]; then
|
if [ "$ipv6_prefixlen" -le 64 ]; then
|
||||||
if [ ! -z "$ipv6_address" ] && [ ! -z "$ipv6_prefixlen" ] && [ ! -z "$ipv6_gateway" ] && [ ! -z "$ipv6_address_without_last_segment" ]; then
|
if [ ! -z "$ipv6_address" ] && [ ! -z "$ipv6_prefixlen" ] && [ ! -z "$ipv6_gateway" ] && [ ! -z "$ipv6_address_without_last_segment" ]; then
|
||||||
pct set $CTID --net0 name=eth0,ip6="${ipv6_address_without_last_segment}${CTID}/128",bridge=vmbr2,gw6="${ipv6_address_without_last_segment}2"
|
pct set $CTID --net0 name=eth0,ip6="${ipv6_address_without_last_segment}${CTID}/128",bridge=vmbr2,gw6="${ipv6_address_without_last_segment}1"
|
||||||
pct set $CTID --net1 name=eth1,ip=${user_ip}/24,bridge=vmbr1,gw=172.16.1.1
|
pct set $CTID --net1 name=eth1,ip=${user_ip}/24,bridge=vmbr1,gw=172.16.1.1
|
||||||
pct set $CTID --nameserver 8.8.8.8,2001:4860:4860::8888 --nameserver 8.8.4.4,2001:4860:4860::8844
|
pct set $CTID --nameserver 8.8.8.8,2001:4860:4860::8888 --nameserver 8.8.4.4,2001:4860:4860::8844
|
||||||
independent_ipv6_status="Y"
|
independent_ipv6_status="Y"
|
||||||
|
|
|
@ -210,7 +210,7 @@ fi
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
pct set $CTID --hostname $CTID
|
pct set $CTID --hostname $CTID
|
||||||
user_ip="172.16.1.${num}"
|
user_ip="172.16.1.${num}"
|
||||||
pct set $CTID --net0 name=eth0,ip6="${ipv6_address_without_last_segment}${CTID}/128",bridge=vmbr2,gw6="${ipv6_address_without_last_segment}2"
|
pct set $CTID --net0 name=eth0,ip6="${ipv6_address_without_last_segment}${CTID}/128",bridge=vmbr2,gw6="${ipv6_address_without_last_segment}1"
|
||||||
pct set $CTID --net1 name=eth1,ip=${user_ip}/24,bridge=vmbr1,gw=172.16.1.1
|
pct set $CTID --net1 name=eth1,ip=${user_ip}/24,bridge=vmbr1,gw=172.16.1.1
|
||||||
pct set $CTID --nameserver 8.8.8.8,2001:4860:4860::8888 --nameserver 8.8.4.4,2001:4860:4860::8844
|
pct set $CTID --nameserver 8.8.8.8,2001:4860:4860::8888 --nameserver 8.8.4.4,2001:4860:4860::8844
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
|
@ -268,7 +268,7 @@ user_ip="172.16.1.${num}"
|
||||||
if [ "$independent_ipv6" == "Y" ]; then
|
if [ "$independent_ipv6" == "Y" ]; then
|
||||||
if [ "$ipv6_prefixlen" -le 64 ]; then
|
if [ "$ipv6_prefixlen" -le 64 ]; then
|
||||||
if [ ! -z "$ipv6_address" ] && [ ! -z "$ipv6_prefixlen" ] && [ ! -z "$ipv6_gateway" ] && [ ! -z "$ipv6_address_without_last_segment" ]; then
|
if [ ! -z "$ipv6_address" ] && [ ! -z "$ipv6_prefixlen" ] && [ ! -z "$ipv6_gateway" ] && [ ! -z "$ipv6_address_without_last_segment" ]; then
|
||||||
qm set $vm_num --ipconfig0 ip6="${ipv6_address_without_last_segment}${vm_num}/128",gw6="${ipv6_address_without_last_segment}2"
|
qm set $vm_num --ipconfig0 ip6="${ipv6_address_without_last_segment}${vm_num}/128",gw6="${ipv6_address_without_last_segment}1"
|
||||||
qm set $vm_num --ipconfig1 ip=${user_ip}/24,gw=172.16.1.1
|
qm set $vm_num --ipconfig1 ip=${user_ip}/24,gw=172.16.1.1
|
||||||
qm set $vm_num --nameserver 8.8.8.8,2001:4860:4860::8888
|
qm set $vm_num --nameserver 8.8.8.8,2001:4860:4860::8888
|
||||||
qm set $vm_num --searchdomain 8.8.4.4,2001:4860:4860::8844
|
qm set $vm_num --searchdomain 8.8.4.4,2001:4860:4860::8844
|
||||||
|
|
|
@ -232,7 +232,7 @@ qm set $vm_num --ide2 ${storage}:cloudinit
|
||||||
qm set $vm_num --nameserver 8.8.8.8,2001:4860:4860::8888
|
qm set $vm_num --nameserver 8.8.8.8,2001:4860:4860::8888
|
||||||
qm set $vm_num --searchdomain 8.8.4.4,2001:4860:4860::8844
|
qm set $vm_num --searchdomain 8.8.4.4,2001:4860:4860::8844
|
||||||
user_ip="172.16.1.${num}"
|
user_ip="172.16.1.${num}"
|
||||||
qm set $vm_num --ipconfig0 ip6="${ipv6_address_without_last_segment}${vm_num}/128",gw6="${ipv6_address_without_last_segment}2"
|
qm set $vm_num --ipconfig0 ip6="${ipv6_address_without_last_segment}${vm_num}/128",gw6="${ipv6_address_without_last_segment}1"
|
||||||
qm set $vm_num --ipconfig1 ip=${user_ip}/24,gw=172.16.1.1
|
qm set $vm_num --ipconfig1 ip=${user_ip}/24,gw=172.16.1.1
|
||||||
qm set $vm_num --cipassword $password --ciuser $user
|
qm set $vm_num --cipassword $password --ciuser $user
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# from
|
# from
|
||||||
# https://github.com/spiritLHLS/pve
|
# https://github.com/spiritLHLS/pve
|
||||||
# 2023.08.20
|
# 2023.08.22
|
||||||
|
|
||||||
|
|
||||||
########## 预设部分输出和部分中间变量
|
########## 预设部分输出和部分中间变量
|
||||||
|
@ -422,13 +422,12 @@ is_private_ipv6() {
|
||||||
|
|
||||||
check_ipv6(){
|
check_ipv6(){
|
||||||
IPV6=$(ip -6 addr show | grep global | awk '{print $2}' | cut -d '/' -f1 | head -n 1)
|
IPV6=$(ip -6 addr show | grep global | awk '{print $2}' | cut -d '/' -f1 | head -n 1)
|
||||||
local response
|
|
||||||
if is_private_ipv6 "$IPV6"; then # 由于是内网IPV6地址,需要通过API获取外网地址
|
if is_private_ipv6 "$IPV6"; then # 由于是内网IPV6地址,需要通过API获取外网地址
|
||||||
IPV6=""
|
IPV6=""
|
||||||
local API_NET=("ipv6.ip.sb" "https://ipget.net" "ipv6.ping0.cc" "https://api.my-ip.io/ip" "https://ipv6.icanhazip.com")
|
API_NET=("ipv6.ip.sb" "https://ipget.net" "ipv6.ping0.cc" "https://api.my-ip.io/ip" "https://ipv6.icanhazip.com")
|
||||||
for p in "${API_NET[@]}"; do
|
for p in "${API_NET[@]}"; do
|
||||||
response=$(curl -sLk6m8 "$p" | tr -d '[:space:]')
|
response=$(curl -sLk6m8 "$p" | tr -d '[:space:]')
|
||||||
if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then
|
if [ $? -eq 0 ] && ! ( echo "$response" | grep -q "error" ); then
|
||||||
IPV6="$response"
|
IPV6="$response"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -789,14 +788,14 @@ check_interface
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
# 检测IPV6相关的信息
|
# 检测IPV6相关的信息
|
||||||
if [ ! -f /usr/local/bin/pve_check_ipv6 ]; then
|
if [ ! -f /usr/local/bin/pve_check_ipv6 ] || [ ! -s /usr/local/bin/pve_check_ipv6 ] || [ "$(sed -e '/^[[:space:]]*$/d' /usr/local/bin/pve_check_ipv6)" = "" ]; then
|
||||||
check_ipv6
|
check_ipv6
|
||||||
fi
|
fi
|
||||||
if [ ! -f /usr/local/bin/pve_ipv6_prefixlen ]; then
|
if [ ! -f /usr/local/bin/pve_ipv6_prefixlen ] || [ ! -s /usr/local/bin/pve_ipv6_prefixlen ] || [ "$(sed -e '/^[[:space:]]*$/d' /usr/local/bin/pve_ipv6_prefixlen)" = "" ]; then
|
||||||
ipv6_prefixlen=$(ifconfig ${interface} | grep -oP 'prefixlen \K\d+' | head -n 1)
|
ipv6_prefixlen=$(ifconfig ${interface} | grep -oP 'prefixlen \K\d+' | head -n 1)
|
||||||
echo "$ipv6_prefixlen" > /usr/local/bin/pve_ipv6_prefixlen
|
echo "$ipv6_prefixlen" > /usr/local/bin/pve_ipv6_prefixlen
|
||||||
fi
|
fi
|
||||||
if [ ! -f /usr/local/bin/pve_ipv6_gateway ]; then
|
if [ ! -f /usr/local/bin/pve_ipv6_gateway ] || [ ! -s /usr/local/bin/pve_ipv6_gateway ] || [ "$(sed -e '/^[[:space:]]*$/d' /usr/local/bin/pve_ipv6_gateway)" = "" ]; then
|
||||||
ipv6_gateway=$(ip -6 route show | awk '/default via/{print $3}' | head -n1)
|
ipv6_gateway=$(ip -6 route show | awk '/default via/{print $3}' | head -n1)
|
||||||
# ip -6 route show | awk '/default via/{print $3}' | head -n1
|
# ip -6 route show | awk '/default via/{print $3}' | head -n1
|
||||||
# if is_private_ipv6 "$ipv6_gateway"; then # 由于是内网IPV6地址,不设置V6地址
|
# if is_private_ipv6 "$ipv6_gateway"; then # 由于是内网IPV6地址,不设置V6地址
|
||||||
|
@ -1173,6 +1172,7 @@ iface vmbr0 inet6 auto
|
||||||
bridge_ports $interface
|
bridge_ports $interface
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
|
ipv6_address_without_last_segment="${ipv6_address%:*}:"
|
||||||
cat << EOF | sudo tee -a /etc/network/interfaces
|
cat << EOF | sudo tee -a /etc/network/interfaces
|
||||||
auto vmbr0
|
auto vmbr0
|
||||||
iface vmbr0 inet static
|
iface vmbr0 inet static
|
||||||
|
@ -1183,7 +1183,7 @@ iface vmbr0 inet static
|
||||||
bridge_fd 0
|
bridge_fd 0
|
||||||
|
|
||||||
iface vmbr0 inet6 static
|
iface vmbr0 inet6 static
|
||||||
address ${ipv6_address}/${ipv6_prefixlen}
|
address ${ipv6_address_without_last_segment}/128
|
||||||
gateway ${ipv6_gateway}
|
gateway ${ipv6_gateway}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue