#!/bin/bash
#setup tap device
ip link show tap0 &>/dev/null
if [ $? != "0" ]; then
echo "adding tap device"
ip tuntap add dev tap0 mode tap
fi
# setup bridge
ip link show br0 &>/dev/null
if [ $? != "0" ]; then
echo "adding bridge br0"
brctl addbr br0
brctl addif br0 tap0
ifconfig br0 up
ifconfig br0 192.168.0.1 netmask 255.255.255.0
ip link set dev tap0 up
如果此时ping不通,检测是否对方能收到收据,如果对方能收到数据,但是不能发出数据,则检测下路由是否配置正确。