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