Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'd like to have a ethernet link between the host and the guest, but I don't understand how to do it.
Bridge, tun/tap, vde... Many methods seems to work, but I always fail with route problems or whatever.
Qemu and most virtual machines use a few ways to connect the client to the host.
In NAT, it uses a software router. The host has some tcp/ip and the client would get a dhcp address from the VM virtual router. Range is dictated by who made the vm. The virtual router won't give dns ip's and in some vm's won't transfer all types of packets.
In Bridged, you usually get a static ip so to speak. The ip should be the same as the hosts. Still the client may need to have extra data to help configure the nic fully.
The last way is a local only between clients.
You don't really use a physical cable. It is all internal to the system. Guess you could but no on does it.
So to answer you problem we may need to go back and have you describe one way and the problem you see. We can then answer the quesion.
The client will attach to the physical nic in the host. It will be in the same range if dhcp. It will be a full partner in the hosts lan/wan but may still need settings in many cases.
I'll have to admit that there are hundreds of web pages devoted. Many of qemu and other vm concepts are the same. Some older qemu stuff is still in. Plenty of options in qemu depending on exact version.
On my home machine, I find that bridging with a tap interface works for me.
When I want to run a VM with networking, I first execute this little script as root.
Code:
#!/bin/sh
#Script to setup a bridge interface for use with qemu
tunctl -u <username> -g kvm # Need to replace <username> with a valid user name on the system
# Assumes that the user is a member of the kvm group
ifconfig eth0 0.0.0.0
ifconfig tap0 0.0.0.0
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 tap0
# Configure the bridge via DHCP
dhcpcd br0
# Load firewall rules for br0
/etc/rc.d/rc.firewall_br0
# Activate the kvm-intel kernel module for use by qemu
modprobe kvm-intel
After using the VM, I can run this little script as root to revert.
Code:
#!/bin/sh
# Script to bring down bridge after use by qemu
ifconfig tap0 down
brctl delif br0 tap0
tunctl -d tap0
ifconfig eth0 down
brctl delif br0 eth0
ifconfig br0 down
brctl delbr br0
# Restart networking
ifconfig eth0 up
dhcpcd -n
# Load firewall rules for eth0
/etc/rc.d/rc.firewall
# Remove the kvm-intel kernel module used by qemu
modprobe -r kvm-intel
For this to work, you will need the tunctl package that is available at SlackBuilds.org
OMG. There's a bundled script that comes with qemu-kvm that does all of this and more, and it is executed automatically, if you attach the VM to a bridge. libvirt will also take care of all this mess for you. and "ifconfig" is deprecated, stop using it.
The OP is using Slackware, as I do, and may not be sympathetic to automatic script execution.
'libvirt' needs some effort to be built for Slackware, and is not necessary to successfully use qemu. As a matter of fact, I do not use it.
'ifconfig' is available in the current version of Slackware and is perfectly capable of the task in hand. Deprecated it may be, but some find it easier to use than the 'ip' alternative.
Please allow other people to use their computers as they choose.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.