Pokazywanie postów oznaczonych etykietą interface. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą interface. Pokaż wszystkie posty

czwartek, 19 września 2013

Create "internal" VLAN for Xen Virtual Machines

1) Add the dummy interface driver to the auto-load modules:

echo dummy >> /etc/modules

2) Configure network interface  ( /etc/network/interfaces)
auto dummy0
iface dummy0 inet static
address 192.168.100.1
netmask 255.255.255.0

3) Bring up the dummy interface
ifup dummy0

4) Add line in : /etc/xen/xend-config.sxp

(network-script 'network-bridge netdev=dummy0')

5) Run the command:

/etc/xen/scripts/network-bridge start netdev=dummy0 antispoof=no

6) Check if pdummy interface is present:
ifconfig pdummy0

pdummy0   Link encap:Ethernet  HWaddr b6:a5:b4:35:a7:1a 
          inet6 addr: fe80::b4a5:b4ff:fe35:a71a/64 Scope:Link
          UP BROADCAST RUNNING NOARP PROMISC  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:532 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:28928 (28.2 KiB)


8) Attach new interface to guest domain :

xm network-attach  example.domain.guest bridge=dummy0 script=vif-bridge mac=00:16:3E:40:22:12

9) Log in to guest domain console and add new interface:


root@debian-xen:/home/shamrock# xm console example.domain.guest


Debian GNU/Linux 6.0 debian hvc0

debian login: root
Password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@debian:~# ifconfig eth1 192.168.100.200 netmask 255.255.255.0
root@debian:~# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:16:3E:40:22:12 
          inet addr:192.168.100.200  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe40:2212/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:608 (608.0 B)  TX bytes:510 (510.0 B)
          Interrupt:244

And add this to /etc/network/interfaces

auto eth1
iface eth1 inet static
 address 192.168.100.200
 gateway 192.168.100.1
 netmask 255.255.255.0

10) In Dom0 edit DomU config and add ew interface:

i.e.: /etc/xen/example.domain.guest

vif         = [ 'ip=212.85.34.12,mac=00:16:3E:0B:0A:83,bridge=eth0', 'ip=192.168.100.100,mac=00:16:3E:D7:9C:F6,bridge=dummy0' ]


11) Last thing is to set the ip_forwarding in the kernel of Dom0 and create NAT rules.

root@debian-xen:/# echo 1 >/proc/sys/net/ipv4/ip_forward
root@debian-xen:/# iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d 0.0.0.0/0 -j MASQUERADE