qemu guest machine visit solution 3: network bridge/tap in physical bridge network (bridge mode)

########## default private network/host only 

lake@lake-Latitude-5491:~/qemu$ brctl  show
bridge name    bridge id        STP enabled    interfaces
virbr0        8000.1687d65902ee    yes        tap0
                                                                    virbr0-nic

####  Physical ethernet   on Host 

lake@lake-Latitude-5491:~/qemu$ ifconfig   eno1
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::95f9:9bf5:853:9cc9  prefixlen 64  scopeid 0x20<link>
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 21  bytes 3735 (3.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 43  bytes 6780 (6.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0x91500000-91520000  

######### new bridge interface 

lake@lake-Latitude-5491:~/qemu$ sudo  brctl   addbr br0 

lake@lake-Latitude-5491:~/qemu$ brctl  show
bridge name    bridge id        STP enabled    interfaces
br0        8000.000000000000    no        
virbr0        8000.1687d65902ee    yes        tap0
                                                                  virbr0-nic

lake@lake-Latitude-5491:~/qemu$ ifconfig  br0 
br0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 5e:1f:b4:56:03:5c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lake@lake-Latitude-5491:~/qemu$ ifconfig   eno1
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::95f9:9bf5:853:9cc9  prefixlen 64  scopeid 0x20<link>
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 21  bytes 3735 (3.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 43  bytes 6780 (6.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0x91500000-91520000  

############# bridge br0 with Physical ethernet: eno1  and bring up DHCP for br0 in outside network 192.168.1.x

lake@lake-Latitude-5491:~/qemu$ sudo brctl    addif br0    eno1 

lake@lake-Latitude-5491:~/qemu$ ifconfig  br0 
br0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 
lake@lake-Latitude-5491:~/qemu$ sudo  ifconfig  br0   up 
lake@lake-Latitude-5491:~/qemu$ ifconfig  br0   
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::e6b9:7aff:fe6a:fce9  prefixlen 64  scopeid 0x20<link>
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 8  bytes 708 (708.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 2026 (2.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 
lake@lake-Latitude-5491:~/qemu$ sudo   dhclient     br0 
lake@lake-Latitude-5491:~/qemu$ ifconfig  br0   
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::e6b9:7aff:fe6a:fce9  prefixlen 64  scopeid 0x20<link>
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 197  bytes 21440 (21.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 157  bytes 17190 (17.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 
################ Try bridge in qemu Guest OS

 

lake@lake-Latitude-5491:~/qemu$ brctl  show
bridge name    bridge id        STP enabled    interfaces
br0        8000.e4b97a6afce9    no               eno1
virbr0        8000.1687d65902ee    yes        tap0
                                                                    virbr0-nic
 

lake@lake-Latitude-5491:~/qemu$ sudo tunctl  -t tap1 
Set 'tap1' persistent and owned by uid 0
lake@lake-Latitude-5491:~/qemu$ sudo brctl  addif br0 tap1 
lake@lake-Latitude-5491:~/qemu$ brctl  show
bridge name    bridge id        STP enabled    interfaces
br0        8000.6eac5b494b0a    no        eno1
                                                               tap1
virbr0        8000.1687d65902ee    yes        tap0
                                                            virbr0-nic

 

##################### Physical network is 192.168.1.0                             

lake@lake-Latitude-5491:~/qemu$ ifconfig   -a 
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::e6b9:7aff:fe6a:fce9  prefixlen 64  scopeid 0x20<link>
        ether 6e:ac:5b:49:4b:0a  txqueuelen 1000  (Ethernet)
        RX packets 2239  bytes 1495904 (1.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2513  bytes 412905 (412.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::95f9:9bf5:853:9cc9  prefixlen 64  scopeid 0x20<link>
        ether e4:b9:7a:6a:fc:e9  txqueuelen 1000  (Ethernet)
        RX packets 2847  bytes 1573904 (1.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2845  bytes 463197 (463.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0x91500000-91520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4949  bytes 8857100 (8.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4949  bytes 8857100 (8.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet6 fe80::1487:d6ff:fe59:2ee  prefixlen 64  scopeid 0x20<link>
        ether 16:87:d6:59:02:ee  txqueuelen 1000  (Ethernet)
        RX packets 209  bytes 19638 (19.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2694  bytes 443183 (443.1 KB)
        TX errors 0  dropped 3 overruns 0  carrier 0  collisions 0

tap1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::6cac:5bff:fe49:4b0a  prefixlen 64  scopeid 0x20<link>
        ether 6e:ac:5b:49:4b:0a  txqueuelen 1000  (Ethernet)
        RX packets 26  bytes 3030 (3.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 12968 (12.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 16:87:d6:59:02:ee  txqueuelen 1000  (Ethernet)
        RX packets 209  bytes 16712 (16.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 304  bytes 316606 (316.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0-nic: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:c8:b6:a2  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lake@lake-Latitude-5491:~/qemu$ sudo  qemu-system-i386  -m  4086M   -hda    disk.img    -netdev tap,id=tapnet,ifname=tap1,script=no -device rtl8139,netdev=tapnet
WARNING: Image format was not specified for 'disk.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

################>>>>>>>>>>>>>>>>>>  Qemu Gust OS get 192.168.1.12 through tap1/br0 network bridge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值