http://www.linux-vserver.org/api.php?action=feedcontributions&user=TTimo&feedformat=atomLinux-VServer - User contributions [en]2024-03-29T07:15:45ZUser contributionsMediaWiki 1.20.2http://www.linux-vserver.org/Networking_vserver_guestsNetworking vserver guests2009-10-01T22:15:34Z<p>TTimo: /* Host as router */</p>
<hr />
<div>Setting up network access to and from your vserver guests.<br />
__TOC__<br />
==Introduction==<br />
<br />
Lets imagine, you have only one external IP -- <code>$EXTIP</code>.<br />
<br />
You want to have several vservers running without worrying about port overlapping.<br />
<br />
Example:<br />
<br />
Two vservers run a default webserver, running on port 80. If each "guest" vserver shares an IP with the host, then the two webservers will conflict.<br />
<br />
One solution is:<br />
<br />
* All vservers are contained in a "virtual lan", say 192.168.1.x<br />
* Each vserver has its own IP<br />
* Control port forwarding on "parent" host. That is, run a router.<br />
<br />
==Configuration==<br />
===Host===<br />
First you need to load the dummy interface driver<br />
# modprobe dummy<br />
<br />
To have it automatically loaded on startup, add<br />
"loopback" to /etc/modules<br />
<br />
Set up <code>dummy0</code> interface on the parent host<br />
# /etc/network/interfaces on a Debian box, <br />
# configure on other distros with your preferred way<br />
auto dummy0<br />
iface dummy0 inet static<br />
address 192.168.1.250<br />
netmask 255.255.255.0<br />
<br />
===Guests===<br />
Set up each guest vserver:<br />
cd /etc/vservers/$VSERVER/interfaces/0<br />
echo dummy0 > dev<br />
echo 192.168.1.1 > ip<br />
echo 1 > name<br />
echo 24 > prefix<br />
Consider using a value of <code>name</code> equal to the last digit of the IP for easy separation.<br />
<br />
===Host as router===<br />
Configure the host to act as a router.<br />
<br />
Enable IP forwarding:<br />
# echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
For internal packets going outside, pretend each packet came from our external IP (put it in one line without backslash):<br />
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 \ <br />
-d ! 192.168.1.0/24 -j SNAT --to-source $EXTIP<br />
For each service that runs on a vserver, map it to an external port. Vserver local address <code>$VHOST</code> and port <code>$INTPORT</code> you select one external port <code>$EXTPORT</code> and run the following (put it in one line without backslash):<br />
# iptables -t nat -A PREROUTING -s ! 192.168.1.0/24 \<br />
-m tcp -p tcp --dport $EXTPORT <br />
-j DNAT --to-destination $VHOST:$INTPORT<br />
That's all!<br />
<br />
==Verifying==<br />
Try <code>ping pool.ntp.org</code> from your vserver -- it should ping fine.<br />
<br />
Try to connect to your <code>$EXTIP:$EXTPORT</code> (from another external host) -- you will successfully connect to service running on a guest vserver.<br />
==See also==<br />
* [[Frequently_Asked_Questions#If_my_host_has_only_one_a_single_public_IP.2C_can_I_use_RFC1918_IP_.28e.g._192.168.foo.bar.29_for_the_guest_vservers.3F |FAQ on private networking]]<br />
* [[Frequently_Asked_Questions#When_I_try_to_ssh_to_the_guest.2C_I_log_into_the_host.2C_even_if_I_installed_sshd_on_the_guest._What.27s_wrong_here.3F |Permit guest sshd to bind to its IP address's port 22]]<br />
* [[Networking_vserver_guests_RHEL|Networking_vserver_guests_RHEL]]<br />
<br />
[[Category:HowTo]]<br />
[[Category:Network]]</div>TTimohttp://www.linux-vserver.org/Installing_32-bit_Fedora_on_64-bit_DebianInstalling 32-bit Fedora on 64-bit Debian2009-10-01T21:41:37Z<p>TTimo: /* Build vserver */</p>
<hr />
<div>Guide to install a 32-bit Fedora guest into a 64-bit Debian host.<br />
__TOC__<br />
==Set up yum repository==<br />
host# mkdir /etc/rpm<br />
host# mkdir /var/lib/rpm<br />
host# apt-get install yum linux32<br />
host# cp -a /usr/lib/util-vserver/distributions/fc6/{yum,yum.repos.d} /etc/vservers/.distributions/fc6<br />
<br />
vserver build does not use /etc/yum*, though you will see an ignorable error message about it if it doesn't exist. <br />
<br />
Edit the files /etc/vservers/.distributions/fc6/yum.repos.d/fedora-{core,updates,extras}.repo<br />
* Uncomment the first baseurl= line of each file (by removing the leading # character)<br />
<br />
===Proxy===<br />
If you use a proxy, append to /etc/vservers/.distributions/fc6/yum/yum.conf (in the [main] section) a line of the form:<br />
proxy=http://proxy.yourcompany.com:3128<br />
<br />
==Build vserver==<br />
host# export ARCH=i386<br />
host# export http_proxy=http://proxy.yourcompany.com:3128<br />
host# linux32 vserver fedora-zod-32-gustname build -m yum --context 42 --hostname=fedora-zod-32-guestname --interface dummy0=eth0:10.0.0.123/8 --rootdir /var/lib/vservers -- -d fc6 -- --arch i386<br />
host# unset ARCH<br />
<br />
you may also create '''/etc/rpm/platform''' file:<br />
<br />
guest# vi /etc/rpm/platform<br />
i386-redhat-linux-gnu<br />
<br />
this way yum and rpm will use i386 packages<br />
<br />
NOTE: You may get an error "AttributeError: 'module' object has no attribute 'Context'" when executing this (Debian Lenny 5.0.3) because the gpgme package is too old. You can simply edit the misc.py file and early out that function that fails and the process will continue just fine. See http://openvz.org/pipermail/users/2009-January/002554.html for details.<br />
<br />
==Verify==<br />
To observe the 32-bitness of the guest's applications, do:<br />
host# linux32 vyum fedora-zod-32-guestname -- install file<br />
host# vserver fedora-zod-32-guestname start<br />
host# vserver fedora-zod-32-guestname enter<br />
fedora-zod-32-guestname# file /bin/ls<br />
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped<br />
or<br />
host# file /var/lib/vservers/fedora-zod-32-guestname/bin/ls<br />
/var/lib/vservers/fedora-zod-32-guestname/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped<br />
==See also==<br />
* [[Building Guest Systems]]<br />
* [[Installing Ubuntu on Debian]]</div>TTimo