From e8b197b5bdaf43f4f55c0c37bf9d1f29627af636 Mon Sep 17 00:00:00 2001 From: spiritLHLS <103393591+spiritLHLS@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:28:18 +0800 Subject: [PATCH] Update network.sh --- network.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/network.sh b/network.sh index 977ece8..3f955d3 100644 --- a/network.sh +++ b/network.sh @@ -1,11 +1,20 @@ #!/bin/bash #from https://github.com/spiritLHLS/pve +# 打印信息 +_red() { echo -e "\033[31m\033[01m$@\033[0m"; } +_green() { echo -e "\033[32m\033[01m$@\033[0m"; } +_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; } +_blue() { echo -e "\033[36m\033[01m$@\033[0m"; } + +# 查询信息 interface=$(lshw -C network | awk '/logical name:/{print $3}' | head -1) ip=$(curl -s ipv4.ip.sb)/24 gateway=$(ip route | awk '/default/ {print $3}') + +# 录入网关 if grep -q "vmbr0" /etc/network/interfaces; then - echo "vmbr0 already exists in /etc/network/interfaces" + echo "vmbr0 已存在在 /etc/network/interfaces" else cat << EOF | sudo tee -a /etc/network/interfaces auto vmbr0 @@ -17,9 +26,8 @@ iface vmbr0 inet static bridge_fd 0 EOF fi - if grep -q "vmbr1" /etc/network/interfaces; then - echo "vmbr1 already exists in /etc/network/interfaces" + echo "vmbr1 已存在在 /etc/network/interfaces" else cat << EOF | sudo tee -a /etc/network/interfaces auto vmbr1 @@ -36,5 +44,8 @@ iface vmbr1 inet static EOF fi +# 重启配置 service networking restart systemctl restart networking.service + +# 配置DHCP