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