mirror of
https://github.com/thelittlerocket/pve.git
synced 2024-11-15 19:44:38 +08:00
Update network.sh
This commit is contained in:
parent
e6788ee7d5
commit
e8b197b5bd
1 changed files with 14 additions and 3 deletions
17
network.sh
17
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
|
||||
|
|
Loading…
Reference in a new issue