diff --git a/docs/en/guide/pve/pve_kvm.md b/docs/en/guide/pve/pve_kvm.md index 563893b482..a63fb028f3 100644 --- a/docs/en/guide/pve/pve_kvm.md +++ b/docs/en/guide/pve/pve_kvm.md @@ -163,13 +163,31 @@ After the setup is completed, you can execute ```cat vmlog``` to view the inform ```shell for vmid in $(qm list | awk '{if(NR>1) print $1}'); do qm stop $vmid; qm destroy $vmid; rm -rf /var/lib/vz/images/$vmid*; done -iptables -t nat -F -iptables -t filter -F -service networking restart -systemctl restart networking.service -systemctl restart ndpresponder.service -iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore -iptables-save > /etc/iptables/rules.v4 +if command -v nft >/dev/null 2>&1; then + for family in ip ip6 inet; do + for table in nat filter; do + nft list table "$family" "$table" >/dev/null 2>&1 && nft flush table "$family" "$table" + done + done +fi +if command -v iptables >/dev/null 2>&1; then + iptables -t nat -F 2>/dev/null || true + iptables -t filter -F 2>/dev/null || true +fi +if command -v ip6tables >/dev/null 2>&1; then + ip6tables -t nat -F 2>/dev/null || true + ip6tables -t filter -F 2>/dev/null || true +fi +if command -v systemctl >/dev/null 2>&1; then + systemctl restart networking.service 2>/dev/null || service networking restart + systemctl list-unit-files | grep -q '^ndpresponder.service' && systemctl restart ndpresponder.service +else + service networking restart +fi +if command -v iptables-save >/dev/null 2>&1 && command -v iptables-restore >/dev/null 2>&1; then + iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore + iptables-save > /etc/iptables/rules.v4 +fi rm -rf vmlog rm -rf vm* ``` diff --git a/docs/en/guide/pve/pve_lxc.md b/docs/en/guide/pve/pve_lxc.md index fec27ab91d..8a5237b6fd 100644 --- a/docs/en/guide/pve/pve_lxc.md +++ b/docs/en/guide/pve/pve_lxc.md @@ -179,16 +179,32 @@ After the setup is complete, you can execute ```cat ctlog``` to view the informa ```shell pct list | awk 'NR>1{print $1}' | xargs -I {} sh -c 'pct stop {}; pct destroy {}' rm -rf ct* -iptables -t nat -F -iptables -t filter -F -ip6tables -t nat -F -ip6tables -t filter -F +if command -v nft >/dev/null 2>&1; then + for family in ip ip6 inet; do + for table in nat filter; do + nft list table "$family" "$table" >/dev/null 2>&1 && nft flush table "$family" "$table" + done + done +fi +if command -v iptables >/dev/null 2>&1; then + iptables -t nat -F 2>/dev/null || true + iptables -t filter -F 2>/dev/null || true +fi +if command -v ip6tables >/dev/null 2>&1; then + ip6tables -t nat -F 2>/dev/null || true + ip6tables -t filter -F 2>/dev/null || true +fi rm -rf /usr/local/bin/ipv6_nat_rules.sh -service networking restart -systemctl restart networking.service -systemctl restart ndpresponder.service -iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore -iptables-save > /etc/iptables/rules.v4 +if command -v systemctl >/dev/null 2>&1; then + systemctl restart networking.service 2>/dev/null || service networking restart + systemctl list-unit-files | grep -q '^ndpresponder.service' && systemctl restart ndpresponder.service +else + service networking restart +fi +if command -v iptables-save >/dev/null 2>&1 && command -v iptables-restore >/dev/null 2>&1; then + iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore + iptables-save > /etc/iptables/rules.v4 +fi ``` ## Creating Virtual Machines with Pure IPv6 Addresses diff --git a/docs/guide/pve/pve_kvm.md b/docs/guide/pve/pve_kvm.md index b1084e130a..6ca70ff18d 100644 --- a/docs/guide/pve/pve_kvm.md +++ b/docs/guide/pve/pve_kvm.md @@ -194,13 +194,31 @@ curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt ```shell for vmid in $(qm list | awk '{if(NR>1) print $1}'); do qm stop $vmid; qm destroy $vmid; rm -rf /var/lib/vz/images/$vmid*; done -iptables -t nat -F -iptables -t filter -F -service networking restart -systemctl restart networking.service -systemctl restart ndpresponder.service -iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore -iptables-save > /etc/iptables/rules.v4 +if command -v nft >/dev/null 2>&1; then + for family in ip ip6 inet; do + for table in nat filter; do + nft list table "$family" "$table" >/dev/null 2>&1 && nft flush table "$family" "$table" + done + done +fi +if command -v iptables >/dev/null 2>&1; then + iptables -t nat -F 2>/dev/null || true + iptables -t filter -F 2>/dev/null || true +fi +if command -v ip6tables >/dev/null 2>&1; then + ip6tables -t nat -F 2>/dev/null || true + ip6tables -t filter -F 2>/dev/null || true +fi +if command -v systemctl >/dev/null 2>&1; then + systemctl restart networking.service 2>/dev/null || service networking restart + systemctl list-unit-files | grep -q '^ndpresponder.service' && systemctl restart ndpresponder.service +else + service networking restart +fi +if command -v iptables-save >/dev/null 2>&1 && command -v iptables-restore >/dev/null 2>&1; then + iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore + iptables-save > /etc/iptables/rules.v4 +fi rm -rf vmlog rm -rf vm* ``` diff --git a/docs/guide/pve/pve_lxc.md b/docs/guide/pve/pve_lxc.md index 943546ff77..a230f7de3f 100644 --- a/docs/guide/pve/pve_lxc.md +++ b/docs/guide/pve/pve_lxc.md @@ -197,16 +197,32 @@ curl -L https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt ```shell pct list | awk 'NR>1{print $1}' | xargs -I {} sh -c 'pct stop {}; pct destroy {}' rm -rf ct* -iptables -t nat -F -iptables -t filter -F -ip6tables -t nat -F -ip6tables -t filter -F +if command -v nft >/dev/null 2>&1; then + for family in ip ip6 inet; do + for table in nat filter; do + nft list table "$family" "$table" >/dev/null 2>&1 && nft flush table "$family" "$table" + done + done +fi +if command -v iptables >/dev/null 2>&1; then + iptables -t nat -F 2>/dev/null || true + iptables -t filter -F 2>/dev/null || true +fi +if command -v ip6tables >/dev/null 2>&1; then + ip6tables -t nat -F 2>/dev/null || true + ip6tables -t filter -F 2>/dev/null || true +fi rm -rf /usr/local/bin/ipv6_nat_rules.sh -service networking restart -systemctl restart networking.service -systemctl restart ndpresponder.service -iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore -iptables-save > /etc/iptables/rules.v4 +if command -v systemctl >/dev/null 2>&1; then + systemctl restart networking.service 2>/dev/null || service networking restart + systemctl list-unit-files | grep -q '^ndpresponder.service' && systemctl restart ndpresponder.service +else + service networking restart +fi +if command -v iptables-save >/dev/null 2>&1 && command -v iptables-restore >/dev/null 2>&1; then + iptables-save | awk '{if($1=="COMMIT"){delete x}}$1=="-A"?!x[$0]++:1' | iptables-restore + iptables-save > /etc/iptables/rules.v4 +fi ``` ## 开设纯IPV6地址的虚拟机