加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config_tap.sh 1012 Bytes
一键复制 编辑 原始数据 按行查看 历史
Quard 提交于 2022-03-02 15:25 . rootfs:add iperf3 and fix config tap script
#!/bin/bash
set -e
MODE=\
"config_tap | \
release_tap"
USER_NAME=$(whoami)
USAGE="usage $0 [$MODE] [<ETH_NAME>] "
if [ $# == 2 ] ; then
ETH_NAME=$1
else
ETH_NAME=enp2s0f0 #eth0
fi
config_tap()
{
brctl addbr br0
ip addr flush dev $ETH_NAME
brctl addif br0 $ETH_NAME
tunctl -t tap0 -u $USER_NAME
brctl addif br0 tap0
ifconfig $ETH_NAME up
ifconfig tap0 up
ifconfig br0 up
ip addr flush dev br0
ip addr flush dev tap0
ip addr flush dev $ETH_NAME
# static
ip addr add 169.254.105.176/16 brd + dev br0
# dynamic
#dhclient -v br0
}
release_tap()
{
brctl delif br0 tap0
tunctl -d tap0
brctl delif br0 $ETH_NAME
ifconfig br0 down
brctl delbr br0
ifconfig $ETH_NAME up
# static
ip addr add 169.254.105.176/16 brd + dev $ETH_NAME
# dynamic
#dhclient -v $ETH_NAME
}
case "$1" in
config_tap)
config_tap
;;
release_tap)
release_tap
;;
--help)
echo $USAGE
exit 0
;;
*)
echo $USAGE
exit 1
;;
esac
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化