#!/bin/bash
# 定义网络接口相关变量
RK_INTERFACE="eno2"
BRIDGE_INTERFACE="br0"

echo "开始网络配置和软件安装..."

# 配置网桥
if ip link show "$BRIDGE_INTERFACE" &> /dev/null; then
    echo "$BRIDGE_INTERFACE 已存在，跳过创建"
else
    echo "正在创建网桥 $BRIDGE_INTERFACE..."
    ip link add name "$BRIDGE_INTERFACE" type bridge
    ip link set "$RK_INTERFACE" down
    ip link set "$RK_INTERFACE" master "$BRIDGE_INTERFACE"
#    ip link set "$BRIDGE_INTERFACE" up
    echo "网桥 $BRIDGE_INTERFACE 创建并配置完成"
fi
# 启动网桥

ip link set "$RK_INTERFACE" up
ip link set "$BRIDGE_INTERFACE" up

echo "虚拟网卡br0创建完成！"