xref: /DragonOS/tools/qemu/ifdown-nat (revision e26ca418df7af685226d12d7f22fe1785ba163e4)
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