<div class="gmail_extra">Did some further refining and testing on this.<br><br>I found that all that needed to be done to create a NAT or private network for your ovirt guests is (in this example we create a NAT network):<br>
<br>1) Login into your ovirt nodes (all will need to have this created consistently across them.<br>
2) connect to qemu/libvirt with "virsh"<br>3) virsh# connect qemu:///system<br>4) username is: vdsm@rhevh<br>5) password is found in the file /etc/pki/vdsm/keys/libvirt_password<br>6) Create a network xml definition like so (in this example NAT):<br>
<network><br> <name>nat</name><br> <uuid>b09d09a8-ebbd-476d-9045-e66012c9e83d</uuid><br> <forward mode='nat'/><br> <bridge name='natbr0' stp='on' delay='0' /><br>
<mac address='52:54:00:9D:82:DE'/><br> <ip address='192.168.1.1' netmask='255.255.255.0'><br> <dhcp><br> <range start='192.168.1.2' end='192.168.1.250' /><br>
</dhcp><br> </ip><br></network><br>7) Save the network definition at /etc/libvirt/qemu/networks (EX: /etc/libvirt/qemu/networks/nat.xml)<br>8) Add the network: virsh# net-define /etc/libvirt/qemu/networks/nat.xml)<br>
9) Set the network to autostart: virsh# net-autostart nat.xml<br>10) If this is NAT you will need to enable packet forwarding in /etc/sysctl.conf (EG: set net.ipv4.ip_forward = 1)<br>11) If you don't want the reboot the host for this to take effect do: echo '1' > /proc/sys/net/ipv4/ip_forward<br>
12) In the ovirt UI select the cluster which contains the hosts on which you created the network<br>13) Create a new logical network with the same name as the bridge name element from the above xml.(EX: natbr0)<br>14) Remember to enable STP in this case since this is a private or NAT network<br>
15) The logical network will be show as non-operational, so we will need to manually online the network.<br> --> vdsm/ovirt network creation seems to be tied to host physical interfaces and does not look at virtual interfaces in this case vdsm kicks in and finds natbr0 and consequently creates vdsm-natbr0 and natbr0-nic but does nothing more to report it back to the ovirt engine. (ovirt developers feel free to comment on this...)<br>
16) Thus since ovirt does not detect that natbr0 exists and is actually online we need to make a quick database modification to force it online so it can actually be used.<br>17) We first need to find out the UUID of natbr0 interface<br>
18) type the following: psql -U postgres engine -c "SELECT <a href="http://network.id" target="_blank">network.id</a> FROM public.network WHERE <a href="http://network.name" target="_blank">network.name</a> = '<natbr0';" (remember to substitute the name you used for the network)<br>
20) This returns you the UUID of the network<br>21) Next we need to online the network now that we know it's UUID<br>22) type the following: psql -U postgres engine -c "update network_cluster set status='1' where network_id='<the network uuid returned from the previous command goes here>';"<br>
23) You should now be able to attach guest vnics to your newly created NAT or private network.<br><br>oVirt developers, any hope of getting this supported officially as part of ovirt? It seems like it would be relatively easy since the functionality exists in libvirt, and vdsm seems to be aware but the hooks into the engine/UI are what seem to be missing.<br>
<br>- DHC <br><br><div class="gmail_quote">On Mon, Apr 23, 2012 at 4:49 PM, Dead Horse <span dir="ltr"><<a href="mailto:deadhorseconsulting@gmail.com" target="_blank">deadhorseconsulting@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have tried to create a NAT network within ovirt for guests to use via libvirt/virsh as the vdsm@rhevh on an ovirt node.<br>
Something like this:<br><br>virsh # net-info nat<br>Name nat<br>UUID b09d09a8-ebbd-476d-9045-e66012c9e83d<br>
Active: yes<br>Persistent: yes<br>Autostart: yes<br>Bridge: natbr0<br><br>virsh # net-list --all<br>Name State Autostart<br>-----------------------------------------<br>nat active yes <br>
vdsm-natbr0 active yes <br>vdsm-ovirtmgmt active yes <br><br>virsh # <br><br>virsh # net-edit nat<br><network><br> <name>nat</name><br> <uuid>b09d09a8-ebbd-476d-9045-e66012c9e83d</uuid><br>
<forward mode='nat'/><br> <bridge name='natbr0' stp='on' delay='0' /><br> <mac address='52:54:00:9D:82:DE'/><br> <ip address='192.168.122.1' netmask='255.255.255.0'><br>
<dhcp><br> <range start='192.168.122.2' end='192.168.122.254' /><br> </dhcp><br> </ip><br></network><br><br>Set net.ipv4.ip_forward = 1 in sysctl.conf<br><br>This is basically the default libvirt NAT network. Connecting a VM directly to it via cli (qemu-kvm) works perfectly fine on the ovirt host itself but the ovirt manager UI does not seem to pick up on it or allow for creation of such a network for guests to use.<br>
Since the ovirt manager UI did not allow I dug into the database and added entries which seem to have been necessary by hand to the following engine database tables:<br>table: network<br>table: network_cluster<br>table: vds_interface<br>
table: vds_interface_statistics<br><br>The result was the network did show up under cluster logical networks. However the network still does not show up under the host Network Interfaces UI. Was able to create VM and attach the natbr0 network to it and NAT was indeed working. (EG: DNSmasq assigned address). The guest was able to communicate out and without extensive testing things seemed to work.<br>
<br>This was very painful to do (and hacky). Thus it would be very nice if since this is OOB functionality of libvirt/KVM, if ovirt would allow for it to be used. The ability to provide NAT or internal networks to guests would quite useful.<br>
<br>- DHC<br>
</blockquote></div><br></div>