[kwlug-disc] Multiple NICs on Ubuntu Server 14.04
CrankyOldBugger
crankyoldbugger at gmail.com
Mon Aug 18 15:44:54 EDT 2014
OK, so far so good..
I found I was having DNS issues with using DHCP, so I opted for static IPs:
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 10.42.1.80
netmask 255.255.255.0
gateway 10.42.1.1
network 10.42.1.0
broadcast 10.42.1.255
nameserver 10.42.1.1
nameserver 209.222.18.222
nameserver 209.222.18.218
nameserver 8.8.8.8
# secondary NIC card
auto eth1
iface eth1 inet static
address 10.42.1.81
netmask 255.255.255.0
network 10.42.1.0
broadcast 10.42.1.255
gateway 10.42.1.1
nameserver 10.42.1.1
nameserver 209.222.18.222
nameserver 209.222.18.218
nameserver 8.8.8.8
# manual - to set 2nd NIC for VMs
#auto br0
#iface br0 inet dhcp
# bridge_ports eth1
# add bridge interface
iface br0 inet static
address 10.42.1.95
network 10.42.1.0
netmask 255.255.255.0
broadcast 10.42.1.255
gateway 10.42.1.1
dns-nameservers 10.42.1.1
dns-nameservers 209.222.18.222
dns-nameservers 209.222.18.218
bridge_ports eth1
bridge_stp off
auto br0
Then I made sure the router's port forwarding was good so I could access
the machine from the office (I have to redirect the ports due to
restrictions at work).
Before I could move to the KVM work I remembered that I neglected to mount
the spare hard drives I had in the host box after the last time I installed
Ubuntu Server, so I used fdisk to partition and prep a HDD for use as my VM
storage area.
So now on to setting up KVM...
I had a copy of Ubuntu Server 14.04 on another server so I wanted to copy
it over to the VM host. Being someone who's snuck by with the GUI, I
wanted to learn to do this via CLI (yes, I've never SCP'd before...). So I
had to appended the remote server's public key to the VM host, the do a scp
copy as such:
scp root at 10.42.1.71:/mnt/HD_a2/Downloads_Storage/OS_ISOs/LinuxOS/ubuntu-14.04-server-amd64.iso
~/iso/ubserver.iso
So this is how I installed KVM and built a VM (pretty much all of this was
run with sudo, so you may want to flip over to 'su'):
aptitude -y install qemu-kvm libvirt-bin virtinst bridge-utils
modprobe vhost_net
lsmod | grep vhost
First we have to make the drive that the VM sits on (for lack of a creative
spark, I'm going to name this test VM "europa"):
fallocate -l 100000M /var/lib/libvirt/images/europa.img
Next, you may need to install virt-install using apt-get.
The actual command to make the VM was:
virt-install -n europa -r 1024 -f /media/vms/europa/europa.img --cdrom
/home/jeff/iso/ubserver.iso --accelerate --vnc --noautoconsole -v --network
bridge:br0
I'm not 100% sure about using br0 as the network bridge. I may have messed
that up...
So this is where I right now.. I know the VM is running because I can run:
virsh list --all
Id Name State
----------------------------------------------------
2 europa running
Now this is where I am stuck. Virt-manager is pretty much useless (you run
it and it just goes away) and virt-viewer is crying about not being able
to find the Display (I am running Ubuntu Server, which is CLI only. Is
that the problem?)
I'm still trying to get past this issue and actually see the VM. I'll let
you know how that goes. If I knew europa's IP or something that I could
connect to...
On 15 August 2014 11:30, Khalid Baheyeldin <kb at 2bits.com> wrote:
> On Fri, Aug 15, 2014 at 10:40 AM, CrankyOldBugger <
> crankyoldbugger at gmail.com> wrote:
>
>>
>> virbr0 Link encap:Ethernet HWaddr ca:e3:65:49:dc:e4
>> inet addr:192.168.122.1 Bcast:192.168.122.255
>> Mask:255.255.255.0
>> UP BROADCAST MULTICAST MTU:1500 Metric:1
>> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>> collisions:0 txqueuelen:0
>> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
>>
>>
>> Don't ask me why virbr0 is there. (Google tells me it's there because I
>> started tinkering with KVM at some point but I never finished the task.)
>>
>
> Yes, I have that too, and yes, it is caused by libvirt/kvm. And it is not
> from configuration in /etc/network/interfaces.
>
>
>> I want to start building virtual machines on this box, but before I do I
>> would like to see the server using both NIC cards appropriately.
>>
>
> You can make both cards work by putting something like this in your
> /etc/network/interfaces
>
>
> auto eth0
> iface eth0 inet dhcp
>
> auto eth1
> iface eth1 inet dhcp
>
> The above will make both interfaces come up at boot, and configure
> themselves via DHCP, so the router assigns them an IP address, ...etc
>
> Or you can assign that manually using something like:
>
> auto eth0
> iface eth0 inet static
> address 192.168.0.2
> netmask 255.255.255.0
> network 192.168.0.0
> broadcast 192.168.0.255
> gateway 192.168.0.1
>
> auto eth1
> iface eth1 inet static
> address 192.168.0.3
> netmask 255.255.255.0
> network 192.168.0.0
> broadcast 192.168.0.255
> gateway 192.168.0.1
>
> This means the first NIC will get 192.168.0.2 and the second will be .3,
> assuming that the router is at .1.
>
>
>> By that I mean it will share the load between any future VMs between the
>> two NICs,
>>
>
> I am not sure what share the load means, or if there is a real answer to
> it as asked. So I will leave that to others who know more than me.
>
>
>> or at least reserve one NIC for the host server and one NIC for the VMs.
>>
>
> This can be done in /etc/network/interfaces as well. Assuming you want the
> VMs to use only the 2nd network card, then you add:
>
> auto br0
> iface br0 inet dhcp
> bridge_ports eth1
>
> And when creating a VM, via libvirt, you say:
>
> sudo virt-install --name vm_name ... --network bridge=br0 ...
>
> This tells libvirt to use the bridge br0, which uses eth1, which you have
> configured separately.
>
> I have not tried this specifically, but it "should work" (yeah, famous
> words!)
>
> (I'm ashamed to say this is much easier in MS Hyper-V, but I would much
>> rather learn how to do this in Linux CLI!)
>>
>
> Tsk tsk tsk ... traitors and infiltrators in our midst ... ;-)
>
>
>> So I guess my question is two-fold:
>>
>> a) how do I tame my NICs in preparation for setting up VMs, and
>>
>
> See above.
>
>
>> b) what's the preferred method for setting up VMs in Ubuntu Server?
>> Does anyone know of a good how-to link?
>>
>
> If you have kvm capable server, then use libvirt. You create VMs using
> virt-install on the command line, and use virt-viewer to see the BIOS and
> console output, and manage them using virsh.
>
> Or wait till November, when I will cover all this in a presentation for
> KWLUG.
> --
> Khalid M. Baheyeldin
> 2bits.com, Inc.
> Fast Reliable Drupal
> Drupal optimization, development, customization and consulting.
> Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra
> Simplicity is the ultimate sophistication. -- Leonardo da Vinci
> For every complex problem, there is an answer that is clear, simple, and
> wrong." -- H.L. Mencken
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20140818/90b6150d/attachment.htm>
More information about the kwlug-disc
mailing list