Finely found time to work this out.
The following steps are what I took to get my KVM VMs to use 2 network cards. One for WAN(public) xxx.xxx.xxx.x and one for LAN(internal) 192.168.1.x
First things first. Setup second nic on your Virtualizor box.
Change to network-scripts dir:
Code cd /etc/sysconfig/network-scripts
Create new network interface config eth1:
Place in that file the following and save it:
Code DEVICE=eth1
ONBOOT=yes
BRIDGE=viifbr1
Now create a new bridged network interface config:
And paste in it the following, being sure to update the IPADDR=192.168.1.4 with the correct ip for your internal network:
Code DEVICE=viifbr1
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.1.4
NETMASK=255.255.255.0
ONBOOT=yes
Now time to bring up the new network:
Then bring up the new bridge:
You should get successful messages.
Now check that they show up in ifconfig:
You should see them.
Lets try to ping our internal network gateway:
Code ping -c 4 192.168.1.1
If you made it this far then it gets trickier from here.
Now you should create a new VM like you normally would assigning public ip address.
Once created note the VID number as we have to manually edit the KVM xml config file.
Stop the newly created VM.
In my case the new VM I created had a VID of 1005. To find this config file I installed mlocate and updated the db on the server by doing the following:
Once installed update the db:
After the db is updated you can run the following to find your config xml. Mine was 1005 so I searched for 1005.xml:
Code locate 1005.xml
/etc/libvirt/qemu/1005.xml
/etc/libvirt/qemu/autostart/1005.xml
/var/run/libvirt/qemu/1005.xml
The file we are looking for is the first one in the list: /etc/libvirt/qemu/1005.xml
Now edit that file:
Code nano /etc/libvirt/qemu/1005.xml
In there you will see a section that looks like this:
Code <interface type='bridge'>
<source bridge='viifbr0' />
<target dev='viif1005'/>
<model type='e1000' />
<mac address='00:12:ce:d1:d1:ee' />
<filterref filter='clean-traffic'>
<parameter name='IP' value='xxx.xxx.xxx.xxx'/>
</filterref>
</interface>
You want to copy that section and paste the same thing in right under the </interface> bit of code. Like this:
Code <interface type='bridge'>
<source bridge='viifbr0' />
<target dev='viif1005'/>
<model type='e1000' />
<mac address='00:12:ce:d1:d1:ee' />
<filterref filter='clean-traffic'>
<parameter name='IP' value='xxx.xxx.xxx.xxx'/>
</filterref>
</interface>
<interface type='bridge'>
<source bridge='viifbr0' />
<target dev='viif1005'/>
<model type='e1000' />
<mac address='00:12:ce:d1:d1:ee' />
<filterref filter='clean-traffic'>
<parameter name='IP' value='xxx.xxx.xxx.xxx'/>
</filterref>
</interface>
Once you have added in the new section you need to make some changes to it so that the new interface in the VM knows what bridge to use.
Update the following lines in red:
<interface type='bridge'>
<source bridge='[color=red]viifbr1[/color]' />
<target dev='[color=red]viiif1005[/color]'/>
<model type='e1000' />
<mac address='00:12:ce:d1:d1:[color=red]ec[/color]' />
<filterref filter='clean-traffic'>
<parameter name='IP' value='[color=red]192.168.1.4[/color]'/>
</filterref>
</interface>
I change the source bridge from viifbr0 to viifbr1, which is our new bridge.
Also had to update the target dev from viif1005 to vii[color=red]i[/color]f1005. Added an extra i so it does not conflict with the creation of new VMs.
You need to change the mac address also. I just changed the last character from e to c.
And last set the ip of the internal nic on the vm.
Save and close your VM xml config.
If everything is configured correctly you should now be able to start your new VM with out issue.
Once your VM is up and running you need to configure a new interface with your private ip address: (debian 6)
Code nano /etc/network/interfaces
Add the following:
Code auto eth1
iface eth1 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1
Save and exit.
Now start up the new nic:
Once up you should now be able to ping the internal gateway:
Code ping -c 4 192.168.1.1
If you cannot ping the gateway you will probably have to setup correct routes.
For me to fix this I had to setup routes so that the traffic knows what gateway to use on the VM.
Ill post my examples of rule but you can find more info on how to do it here: http://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/
This is for a Debian 6 VM:
Code echo "1 admin" >> /etc/iproute2/rt_tables
ip route add xxx.xxx.xxx.0/24 dev eth0 src xxx.xxx.xxx.xxx table admin
ip route add default via ggg.ggg.ggg.ggg dev eth0 table admin
ip rule show
ip rule add from xxx.xxx.xxx.xxx/32 table admin
ip rule add to xxx.xxx.xxx.xxx/32 table admin
ip rule show
ip route flush cache
Of course update your public ip address where the xxx are. Fill in your ip up to the .0 part or it will not work. Where ggg.ggg.ggg.ggg is you want to put your Public IP gateway.
I hope this info will help a few of you that had the same problem as me.
I'll do my best to answer any questions you may have provided the staff even allows this to be posted.
Thanks,
Casey
Comment from dalem
make sure to chattr the 1005.xml file
pretty sure virtualizor will overwrite it
it does with xen
|