0

I have a qemu machine that i connect to the network using a bride virtual network but since I am using a bridge interface the host can't connect to the internet and the lan.

is there any way to have the guest and the host in the same network given by the router (192.168.1.0/24) so both can access to internet and lan? With the bridge network of course the host does not have internet and lan access

0

There are several options for internet access with qemu, including bridging and sharing the interface with NAT.

From the command line, my VM uses the following net device options for a NAT interface:

-netdev tap,fd=26,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:2b:4f:a8,bus=pci.0,addr=0x3

with these iptables rules in POSTROUTING:

Chain POSTROUTING (policy ACCEPT 36650 packets, 6409K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    5   312 RETURN     all  --  *      *       192.168.122.0/24     224.0.0.0/24        
    0     0 RETURN     all  --  *      *       192.168.122.0/24     255.255.255.255     
    5   300 MASQUERADE  tcp  --  *      *       192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
   10  1380 MASQUERADE  udp  --  *      *       192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
    0     0 MASQUERADE  all  --  *      *       192.168.122.0/24    !192.168.122.0/24    

These are the defaults configured by virt-manager, which is much simpler and easier than building up your command line. For example, it also configures a DNS caching server and a DHCP server. Virt-manager also gives you the option of selecting interfaces to bridge, or selecting a NAT configuration on your primary interface, all with just a drop-down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.