xref: /DragonOS/tools/qemu/ifdown-nat (revision 03746da3d9f3ea616cecdb6e581414002075f866)
1#!/bin/bash
2BRIDGE=dragonos-bridge
3if [ -n "$1" ]; then
4        echo "正在断开接口 $1"
5        ip link set $1 down
6        brctl delif "$BRIDGE" $1
7        tap=`brctl show | grep natnet | awk '{print $4}'`
8        if [[ $tap != tap* ]];then
9            ip link set "$BRIDGE" down
10            brctl delbr "$BRIDGE"
11            iptables -t nat -F
12            kill `ps aux | grep dnsmasq | grep -v grep | awk '{print $2}'`
13            echo "断开接口 $1 成功"
14            echo "网桥 $BRIDGE 卸载成功"
15            echo "dnsmasq 服务停止成功"
16            exit 0
17        else
18            echo "断开接口 $1 成功"
19            exit 0
20        fi
21else
22        echo "删除错误:未指定接口"
23        exit 1
24fi
25