LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization
User Name
Password
Linux - Virtualization This forum is for the discussion of all topics relating to Linux Virtualization. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices

Reply
 
LinkBack Search this Thread
Old 09-30-2011, 02:23 AM   #1
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Rep: Reputation: 0
KVM network problem.


Hi,

I'm having problems with the network in Cent OS 6.0.

My Cent OS 6.0 host has IP 192.168.10.40. The gateway 192.168.10.1.
I want to create a Cent OS 6.0 guest with IP 192.168.10.41, so that all the clients on network 192.168.10.x can access this virtual server with ssh/telnet. Is this not possible ?

I can't get it to work. In Cent OS 5.7 it just worked out of the box. Because xen was with bridge network as default. Now in kvm its NAT. Så I just get a DHCP adress of something like 192.168.122.x.
So I have found out, that I must define a bridge network i kvm. But how ?

I've read the RH Virtualization doc and don't find the solution there and googlet alot.

Help will be apreciated.

Regards Thomas
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-30-2011, 02:56 AM   #2
Greenfuse
Member
 
Registered: Nov 2004
Distribution: gentoo, arch centos
Posts: 152

Rep: Reputation: 20
create /etc/sysconfig/network-scripts/ifcfg-br0 by copying it from /etc/sysconfig/network-scripts/ifcfg-eth0 then edit both files to match what you need, something like I have listed below


/etc/sysconfig/network-scripts/ifcfg-br0
Code:
DEVICE="br0"
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.10.40
GATEWAY=192.168.10.1
DELAY=0

/etc/sysconfig/network-scripts/ifcfg-eth0
Code:
DEVICE="eth0"
ONBOOT=yes
TYPE=Ethernet
HWADDR=00:12:13:14:AB:CD
BRIDGE=br0
Then do 'service network restart'

Last edited by Greenfuse; 09-30-2011 at 02:58 AM.
 
2 members found this post helpful.
Old 09-30-2011, 04:15 AM   #3
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Thans :-) So simple, when seeing it.

Many thanks. It works now !

Regards
 
Old 10-05-2011, 11:39 PM   #4
spankbot
Member
 
Registered: Aug 2007
Posts: 130

Rep: Reputation: 15
Quote:
Originally Posted by Greenfuse View Post
create /etc/sysconfig/network-scripts/ifcfg-br0 by copying it from /etc/sysconfig/network-scripts/ifcfg-eth0 then edit both files to match what you need, something like I have listed below


/etc/sysconfig/network-scripts/ifcfg-br0
Code:
DEVICE="br0"
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.10.40
GATEWAY=192.168.10.1
DELAY=0

/etc/sysconfig/network-scripts/ifcfg-eth0
Code:
DEVICE="eth0"
ONBOOT=yes
TYPE=Ethernet
HWADDR=00:12:13:14:AB:CD
BRIDGE=br0
Then do 'service network restart'
I'm new to KVM networking and have a few questions. The commands above just creates a bridge, correct? You would still need to create a virtual interface and add it to the bridge?
 
Old 10-06-2011, 06:02 AM   #5
Greenfuse
Member
 
Registered: Nov 2004
Distribution: gentoo, arch centos
Posts: 152

Rep: Reputation: 20
When you create the file for br0 as above and restart the network on the host machine then /dev/br0 becomes available as a bridged network interface It will effectively replace eth0 on the host machine as the network interface.

When you create a guest virtual machine you can select br0 as the interface for the guest system to connect through. (I have only done this with virt-manager - it will be available to select within the properties of the guest networking device). The network interface in the guest machine can be given an IP address which is in the same subnet as the host machine and it will function in the network as if it was a physical machine within the network.

I hope this helps make it more clear

Last edited by Greenfuse; 10-06-2011 at 06:12 AM.
 
1 members found this post helpful.
Old 10-06-2011, 04:17 PM   #6
spankbot
Member
 
Registered: Aug 2007
Posts: 130

Rep: Reputation: 15
Thats very helpful, Greenfuse. Thanks.

So does anyone know what the qemu -net option would look like in order to get your vm to use this interface? I'm obviously not using virt-manager...
 
Old 10-06-2011, 05:00 PM   #7
spankbot
Member
 
Registered: Aug 2007
Posts: 130

Rep: Reputation: 15
ok, I answered my own question. For those of use not using virt-manager, you still need to create a virtual interface (tap0) and add it to the bridge (br0) using the bridge-utils and tunctl packages. I use a script to do this right before the VM starts.


Code:
#!/bin/sh
# qemu startup script
# 
# This script first creates a virtual network interface (tap0) for the vm and adds it to the bridge (br0) before starting qemu.
# 
/usr/sbin/tunctl -b
/sbin/ifconfig tap0 up
/usr/sbin/brctl addif br0 tap0
qemu-system-x86_64 -hda disk.img -boot d  -m 1024 -net nic -net tap,ifname=tap0,script=no -no-acpi
This is for an old Ubuntu 6 vm, by the way...

I wrote this all up in more detail here: http://www.kevitivity.com/2011/10/br...with-kvm-qemu/

Last edited by spankbot; 10-06-2011 at 06:52 PM.
 
Old 01-19-2012, 08:35 PM   #8
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 16; Arch; Linux Mint/Ubuntu
Posts: 643

Rep: Reputation: 31
I have a question - do you need to create a brX for each VM if you want each one to have its own IP address?
 
Old 01-20-2012, 01:34 AM   #9
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Hi,
No you don't need to.
 
Old 01-20-2012, 07:34 AM   #10
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 16; Arch; Linux Mint/Ubuntu
Posts: 643

Rep: Reputation: 31
Just need to make sure I understand. in the ifcfg-br0 you set an IP address. If I were to have 5 VMs all running at the same time connected to br0, they could all have different IPs addresses that everyone in the network could address?
 
Old 01-20-2012, 04:24 PM   #11
dyasny
Member
 
Registered: Dec 2007
Location: Israel
Distribution: RHEL,Fedora
Posts: 566

Rep: Reputation: 58
think of br0 as the switch, the other vms are plugged into. it's own ip belongs to the host, not the vms
 
Old 01-20-2012, 07:48 PM   #12
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 16; Arch; Linux Mint/Ubuntu
Posts: 643

Rep: Reputation: 31
OH, that makes a lot more sense. Now if only the br0 could work nicely with network manager, I'd be in business!
 
Old 01-22-2012, 01:08 PM   #13
dyasny
Member
 
Registered: Dec 2007
Location: Israel
Distribution: RHEL,Fedora
Posts: 566

Rep: Reputation: 58
No, NM is a bad bad bad idea when working with bridges. Just set everything up manually, and let it work.
 
Old 01-22-2012, 07:07 PM   #14
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 16; Arch; Linux Mint/Ubuntu
Posts: 643

Rep: Reputation: 31
yeah, I get that. But it'd be nice if it would work correclty
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
KVM on Redhat 5.7: KVM can ping outside network, outside network can't ping KVM svandyk Linux - Networking 1 09-23-2011 06:45 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization 2 03-21-2011 02:05 PM
KVM Network problems in FC13 mickeyboa Fedora 7 06-26-2010 04:48 PM
Problem setting network for KVM Khao8 Linux - Networking 1 09-11-2009 05:05 AM
kvm wireless bridge network shogun1234 Debian 4 01-11-2009 07:10 AM


All times are GMT -5. The time now is 02:08 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration