chenyi852 / chenyi852.github.com

It's my first blog
Apache License 2.0
0 stars 0 forks source link

如何配置qemu的网络 #23

Open chenyi852 opened 4 years ago

chenyi852 commented 4 years ago
#!/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不通,检测是否对方能收到收据,如果对方能收到数据,但是不能发出数据,则检测下路由是否配置正确。