#!/bin/bash 配置变量 declare -A ACCOUNTS=( ["101"]="091246017239" ["102"]="091246176158"…
- User
#!/bin/bash
配置变量
declare -A ACCOUNTS=( ["101"]="091246017239" ["102"]="091246176158" ["103"]="091246176253" ["107"]="091246190492" ["108"]="091246190881" ["110"]="091246191005" ) VLANS=("101" "102" "103" "107" "108" "110") PASSWORD="123456" INTERFACE="ens160" CONNECTIONS_PER_VLAN=250
分配每个 VLAN 的 TABLE_ID
declare -A VLAN_TABLE_IDS=( ["101"]=10 ["102"]=11 ["103"]=12 ["107"]=13 ["108"]=14 ["110"]=15 )
清理现有配置和日志
echo "Cleaning up existing connections and logs..." killall pppd 2>/dev/null rm -f /var/log/ppp/ppp_*.log sleep 2
在清理现有配置部分添加
清理现有路由规则
echo "Cleaning up existing routing rules..." ip rule show | grep -v "from all" | while read line; do ip rule del
echo $line | sed 's/:.*//'done清理路由表文件中的 PPP 条目
sed -i '/^2[0-9][0-9] ppp/d' /etc/iproute2/rt_tables
删除现有 macvlan 接口
for vlan in "(seq 1 {INTERFACE}_mac{i}" if ip link show "MACVLAN_INTERFACE..." ip link set "MACVLAN_INTERFACE" type macvlan fi done done
- Assistant