xen creating a new virtual machine with bridge networking
Solution 1
First of all if you are using VirtualBox to host the XEN server please ensure to use Ethernet not Wireless network and set Promiscuous Mode to "Allow All".
Secondly just to make everything clean, let's start with clean installation of CentOS with XEN and install the Bridge Network and CentOS VM on it.
Assuming you have external server 192.168.1.6 with CentOS ISO extracted on /var/www/html/centos/6.3/os/i386/ and kickstart file on /var/www/html/centos/6.3/os/i386/ks.cfg and /var/www/html/centos/6.3/os/i386/repodata with correct names match names in repodata/TRANS.TBL file
On the XEN server (CentOS+XEN) install the following packages:
yum install -y rsync wget vim-enhanced openssh-clients
yum install -y libvirt python-virtinst libvirt-daemon-xen
yum install -y bridge-utils tunctl
Then edit ifcfg-* file to create the bridge, no need for NM_CONTROLLED=no in CentOS:
echo "DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes" > /etc/sysconfig/network-scripts/ifcfg-br0
echo "DEVICE=eth0
HWADDR=XX:XX:XX:XX:XX:XX
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
BRIDGE=br0" > /etc/sysconfig/network-scripts/ifcfg-eth0
edit HWADDR=XX:XX:XX:XX:XX:XX
line to match your MAC address.
Don't reboot on ssh console, use VBox console
reboot
after reboot, assuming you have DHCP server the XEN server will got a new IP, login via VBox console to get the new IP
ifconfig result should be similar to
br0 Link encap:Ethernet HWaddr 08:00:27:23:54:69
inet addr:192.168.1.105 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe23:5469/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5063 errors:0 dropped:0 overruns:0 frame:0
TX packets:3142 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:34251267 (32.6 MiB) TX bytes:361205 (352.7 KiB)
eth0 Link encap:Ethernet HWaddr 08:00:27:23:54:69
inet6 addr: fe80::a00:27ff:fe23:5469/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:149910 errors:0 dropped:0 overruns:0 frame:0
TX packets:5045 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:182020057 (173.5 MiB) TX bytes:493792 (482.2 KiB)
Now the bridge is ready you can use the IP of br0 to get ssh console again
To create a virtual machine on XEN which use previous bridge:
cd /var/lib/xen/images/
Create virtual disk:
dd if=/dev/zero of=centos_1.img bs=4K count=0 seek=1024K
qemu-img create -f raw centos_1.img 8G
Then use virt-install to create the VM:
virt-install -d -n TestVM1 -r 512 --vcpus=1 \
--bridge=br0 --disk /var/lib/xen/images/centos_1.img \
--nographics -p -l "http://192.168.1.6/centos/6.3/os/i386" \
--extra-args="text console=com1 utf8 console=hvc0 ks=http://192.168.1.6/centos/6.3/os/i386/ks.cfg"
Now the VM should start and be able to get IP from the DHCP server normally and able to complete unattended remote installation.
The ifconfig result on XEN should be similar to:
br0 Link encap:Ethernet HWaddr 08:00:27:23:54:69
inet addr:192.168.1.105 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe23:5469/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10247 errors:0 dropped:0 overruns:0 frame:0
TX packets:8090 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:102264338 (97.5 MiB) TX bytes:827859 (808.4 KiB)
eth0 Link encap:Ethernet HWaddr 08:00:27:23:54:69
inet6 addr: fe80::a00:27ff:fe23:5469/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:998780 errors:0 dropped:0 overruns:0 frame:0
TX packets:37992 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:724701715 (691.1 MiB) TX bytes:2897912 (2.7 MiB)
vif5.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37 errors:0 dropped:0 overruns:0 frame:0
TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:4381 (4.2 KiB) TX bytes:9842 (9.6 KiB)
After the installation complete you can use xen console to get the IP of it, then you can have ssh console on it.
Solution 2
1 - Check you can ping xc63 IP address from another host on network
2 - Check that the url works from other hosts on the same network.
3 - Check your web server logs. Or firewall rules
Related videos on Youtube
Steve
Updated on September 18, 2022Comments
-
Steve over 1 year
I am using CentOS 6.5 64
use this tutorial to setup Bridge
[root@CentOS ~]# brctl show bridge name bridge id STP enabled interfaces xenbr0 8000.08002754b3fa yes eth0
create a new virtual machine (CentOS) using
xm
command and everything okXen configuration file
kernel = "/var/lib/xen/images/vmlinuz" ramdisk = "/var/lib/xen/images/initrd.img" extra = "text ks=http://192.168.1.8/kickstart-minimal6-x86_64.cfg" name = "xc63" memory = "512" disk = [ "file:/var/lib/xen/images/centos63.img,xvda,w","file:/var/lib/xen/images/centos63.swp,xvdb,w"] vif = [ 'bridge=xenbr0' ] vcpus = 1 on_reboot = "destroy" on_crash = "destroy"
after create
[root@CentOS ~]# brctl show bridge name bridge id STP enabled interfaces xenbr0 8000.08002754b3fa yes eth0 vif6.0 [root@CentOS ~]# ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:54:B3:FA inet6 addr: fe80::a00:27ff:fe54:b3fa/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3884 errors:0 dropped:0 overruns:0 frame:0 TX packets:2832 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:310622 (303.3 KiB) TX bytes:412047 (402.3 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 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) vif6.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:32 RX bytes:928 (928.0 b) TX bytes:2192 (2.1 KiB) xenbr0 Link encap:Ethernet HWaddr 08:00:27:54:B3:FA inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe54:b3fa/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2935 errors:0 dropped:0 overruns:0 frame:0 TX packets:1403 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:188677 (184.2 KiB) TX bytes:271882 (265.5 KiB)
xm console xc63
This mean that my bridge not working because vm can't call
192.168.1.8
get the MAC address for
xc63
[root@CentOS xen]# xl network-list xc63 Idx BE Mac Addr. handle state evt-ch tx-/rx-ring-ref BE-path 0 0 00:16:3e:21:f4:e1 0 4 10 768/769 /local/domain/0/backend/vif/3/0
and check DHCP status
xc63 get ip
192.168.1.118
ping
from same host it working
[root@CentOS xen]# ping 192.168.1.118 PING 192.168.1.118 (192.168.1.118) 56(84) bytes of data. 64 bytes from 192.168.1.118: icmp_seq=1 ttl=64 time=2.28 ms 64 bytes from 192.168.1.118: icmp_seq=2 ttl=64 time=0.907 ms 64 bytes from 192.168.1.118: icmp_seq=3 ttl=64 time=0.724 ms 64 bytes from 192.168.1.118: icmp_seq=4 ttl=64 time=0.809 ms ^C --- 192.168.1.118 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3171ms rtt min/avg/max/mdev = 0.724/1.181/2.284/0.640 ms
from any device on local network
Request timed out
C:\Users\motaz>ping 192.168.1.118 Pinging 192.168.1.118 with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 192.168.1.118: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Any one who can give me an idea to solve this, i'll be grateful.
-
Andreas Wiese about 10 yearsFollowing your description,
192.168.1.8
is on the local network, not on the host machine, right? Have you enabled IP forwarding on the host machine? -
Tarek about 10 yearsI don't think the problem is in the bridge, are you sure that the configuration file's syntax is correct, or the file is reachable ?
-
Steve about 10 years@AndreasWiese yes
192.168.1.8
on local network, no I did not enable IP forwarding can you explain more ? -
alxgomz about 10 yearsYou dont need ip forwarding as the traffic good through the bridge. This is not routing.
-
Steve about 10 yearsstoped the iptables dropbox.com/s/qa1rrlyotubbk4t/…
-
Steve about 10 yearsplease check update of the question
-
-
Steve about 10 years1. how to get the ip of xc63 2. the url working 100% from local nework
-
Steve about 10 years3. log not change :(
-
Steve about 10 yearsplease check update of the question
-
alxgomz about 10 yearsIf DHCP is working then tour bridge setup is OK. You may have firewall rules involved... Maybe on the hypervisor. Check if you can ping 192.168.1.2 from xc63. And Check the output of iptables -nvL on the hypervisor.
-
Steve about 10 yearsxc63 not finish install i can't ssh to it. how to check the output of iptables -nvL plz help me I spend more than 20 hour on it
-
Steve about 10 yearsthe result of
iptables -nvL
image -
alxgomz about 10 yearsMy advice is to check firewall on the hypervisor not on the xc63 host.
-
alxgomz about 10 yearsWhat about pinging the IP of xenbr0 from xc63
-
Steve about 10 yearsxc63 not finish install i can't ssh to it, I am sorry if I don't understand
-
Steve about 10 yearsi am using the local network to install OS on xc63