Here's how I do it..
I have a VM host and a bunch of VM guests on it. Most of those guest VMS
are in the same vlan as the host, which works fine with bridge. Some are
in tagged vlans, but you didn't ask about that.
from the guest perspective, here's an example from the .xml
<interface type='network'>
<mac address='52:54:00:b0:98:0b'/>
<source network='default'/>
<model type='rtl8139'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03'
function='0x0'/>
</interface>
host:
[root@vm2 qemu]# cat networks/default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made
using:
virsh net-edit default
or other application using the libvirt API.
-->
/etc/libvirt/qemu/networks/default.xml:
<network>
<name>default</name>
<uuid>57f11311-c17e-4550-8450-bea1c69d36cc</uuid>
<forward mode='bridge'/>
<bridge name='br0'/>
</network>
host (centos) /etc/sysconfig/network-scripts/ifcfg-br0: (note br0 uses
em0 on the hardware exclusively)
DEVICE="br0"
NAME="br0"
ONBOOT="yes"
BOOTPROTO="none"
HWADDR=c8:1f:66:e3:de:58
IPADDR=10.0.2.36
NETMASK=255.255.255.0
DEFROUTE="yes"
GATEWAY=10.0.2.1
TYPE="bridge"
# virsh
virsh # net-list
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
virsh # net-info default
Name: default
UUID: 57f11311-c17e-4550-8450-bea1c69d36cc
Active: yes
Persistent: yes
Autostart: yes
Bridge: br0
a guest (centos) /etc/sysconfig/network-scripts/ifcfg-eth0:
TYPE=Ethernet
BOOTPROTO=static
HWADDR=52:54:00:6f:f7:85
USERCTL=no
IPADDR=10.0.2.27
NETMASK=255.255.255.0
GATEWAY=10.0.2.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8
DNS2=8.8.4.4
DOMAIN=foo.bar
UUID=8c4d5363-3bea-409f-8965-f2db432a6853
On 12/6/2017 11:57 PM, scar wrote:
I can't seem to figure out how to setup a public IP for the VM so
we
could use it as a second public webserver. The host machine runs our
primary webserver with CentOS 6.9 and one public ipv4 address
configured on physical interface eth0. Now i have configured a new
bridge interface br0:
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
The IP settings are for a second public ipv4 address in the same
network. Now i setup the VM to use br0 for the NIC and set the same
IP settings inside the VM... but it doesn't work. The VM can't
resolve any hosts, and if i try to ssh to the second public IP, it
just sends me to the host machine instead of the VM.
_______________________________________________
libvirt-users mailing list
libvirt-users(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-users
--
Doug Hughes
Keystone NAP
Fairless Hills, PA
1.844.KEYBLOCK (539.2562)