Monday, September 28, 2009

How to enable TUN/TAP on openvz for a container

Login to the main node
First you have to check mod tun
by
#lsmod | grep tun
if you do not see anything then run

#modprobe tun
now again run
#lsmod | grep tun
you will see something like
tun 47872 0

#vzctl set VPSID --devices c:10:200:rw --save
#vzctl set VPSID --capability net_admin:on --save
#vzctl exec VPSID mkdir -p /dev/net
#vzctl exec VPSID mknod /dev/net/tun c 10 200
#vzctl exec VPSID chmod 600 /dev/net/tun

That's it.

:)

Thursday, September 10, 2009

Restore backups in windows virtuozzo from one node to another

Dump all the c:\vz\backups folders to new server in c:\vz\backups
Then run
vzbackupsync.exe at the command prompt. It will rsync the backup database in the system. Now you can restore the vps.

Good luck.

how to run rsync command remotely

I wanted to rsync the data from one node to other but I was frustrated by the rsync error of cod 12 at io.c 463. It was like this

[root@192.168.1.100]# rsync -racv -e "ssh -l root" /vz/private/130 192.168.1.1:/vz/private
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(463) [sender=2.6.8]

Connection from 192.168.1.100 were giving errors while connecting to the 192.168.1.1

But the connection from 192.168.1.1 to 192.168.1.100 were fine. So I modified the command to trigger the backup from 192.168.1.1 to 192.168.1.100. Command exectuted at 192.168.1.1

[root@192.168.1.1]# rsync -racv -e "ssh -l root" 192.168.1.100:/vz/private/130 /vz/private

Now the data from 192.168.1.100 is dumping to the 192.168.1.1

Took sometime to find the resolution for code 12 but no results on yahoo or google. Will still look the resolution but till that time I running dump... lol

how to tar gunzip untar folder in linux

How to tar gunzip untar the folders in linux
SSH to linux or login as root
make a test folder
#mkdir test
Now tar gunzip this folder by the name whatever
# tar -czf whatever.tar.gz test
Now remove the test folder which you gunzip tar.
#rm -fdr test
Now untar the whatever.tar.gz
#tar -zxvf whatever.tar.gz
Now you see test folder is there.

Enjoy!!!

Tuesday, September 8, 2009

APF firewall settings for openvz

1. First of all, you should define which iptables modules are available for VEs.

Edit /etc/sysconfig/iptables-config file on a Virtuozzo hardware node:
IPTABLES_MODULES="ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"

Edit /etc/sysconfig/vz file on a Virtuozzo hardware node:
IPTABLES="ipt_REJECT
ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"

Please note - iptables modules list in IPTABLES and IPTABLES_MODULES parameters in /etc/sysconfig/vz and /etc/sysconfig/iptables-config files should be placed in one single line, no linebreaks is allowed in this parameter.

Restart Virtuozzo. All VEs will be restarted.
# service vz restart

2. Increase 'numiptent' parameter for the VE you need to install APF into. This parameter limits the amount of iptables rules available for a VE. Default APF configuration requires ~400 rules. Lets set it to 400 in the example below for VE #101:
# vzctl set 101 --numiptent 400 --save

3. Install APF inside the VE. Edit /etc/apf/conf.apf inside VE, set the following parameters:
IFACE_IN="venet0"
IFACE_OUT="venet0"
SET_MONOKERN="1"

4. Start APF inside the VE:
# /etc/init.d/apf start