Pages

Tuesday, March 25, 2014

ARP with OpenVZ

Your OpenVZ VPS may got inaccessible due to the ARP conflict.   This problem is not a bug or a server configuration issue, its caused by the network configuration at your data-centre and the way that OpenVZ networking works.

OpenVZ VPS don't have their own network interfaces or mac addresses, instead it uses an internal Proxy/ARP based IP forwarding system, which forwards packets via the host machine.

The switch or router your node is connected to will have an ARP table which is a list of IP Addresses and the mac addresses they are routed to. This gets updated whenever an IP is accessed from a system.

When a VPS is initially created, the IP is brought up through the node and the ARP table is updated with the mac address of the node, which then forwards packets to the VPS.

If you have a VPS suspended or offline for some time, that entry in the ARP table on the switch/router will timeout and be removed. When you un-suspend or boot the VPS, the ARP table will not be updated because the VPS does not have its own mac address, and the router won't know what to do with that IP. 

This description may not be 100% accurate depending on how your datacentre has configured their network, but that's what's happening. When the VPS is offline, the router is losing it's entry of where it needs to route that IP Address.

The only way to get around the problem is to bring up the IP on the node's interface e.g. as eth0:0 or eth0:1, then ping it which will update the router's table. Then you can remove it from the node and boot the VPS.

A permanent solution would be to use a virtualization technology such as Xen or KVM, where each VPS has its own unique mac address, or find an alternate provider unless they can help you resolve this. 


(1) You can add the arp entries for the IPs on the actual virtual environment as follows

#arp -s [INSERT IP HERE] `ifconfig eth0 | grep eth0 | awk '{print $5}'` pub

Make sure you run the command above for every IP on the VPS

(2) To delete the entry from the ARP cache:

#arp -d <IP_ADDRESS>

If you get an error “SIOCDARP(pub): No such file or directory”, then you should provide an extra argument to the above command

# arp -d <IP_ADDRESS> -i <ethernet_interface>

Migrate the Emails using imapsync


To migrate an email account sales@example.com from server1.example.com to server2.example.com, please do the following.
server1.example.com (source)
server2.example.com (target)
First create the corresponding email account (sales@example.com) at the destination.
Install "imapsync" utility on your Linux machine.
Save the passwords of your email accounts in the corresponding files and change the permission to 600 as given below.
/etc/secret1 contains the password of the source email account.
/etc/secret2 contains the password of the destination email account.
Changing permission.
chmod 600 /etc/secret1
chmod 600 /etc/secret2
Initiate the following command and wait for the process to complete.
imapsync --host1 server1.example.com --user1 sales@example.com --passfile1 /etc/secret1 --host2 server2.example.com --user2 sales@example.com --passfile2 /etc/secret2

Read-only locking type set. Write locks are prohibited. (LVM)

If you receive the following error while creating the LVM, here is the fix
-----------------------------
Read-only locking type set. Write locks are prohibited.
Can't get lock for Xen1
-----------------------------
[root@test~]# grep locking_type /etc/lvm/lvm.conf
locking_type = 4
Check locking_type in the lvm config and change it to 1

Compile kernel source rpm and biuild with .spec file

Here we are recompiling source rpm with latest linux kernel(kernel.org)
(1) Download the source rpm
http://repo.smartservermanagement.com/el6/x86_64/kernel-xen-3.4.58-1.src.rpm
(2) Installed the source RPM
#rpm -ivh kernel-xen-3.4.58-1.src.rpm
This wil create rpbnild folder under /root

cd /root/rpmbuild/SPECS/
vi kernel-xen.spec
(Changed .58 to 80))
(3)Downloaded the kernel source from kernel.org(3.4.80) to /root/rpmbuild/SOURCES/
cd /root/rpmbuild/SPECS
(4)Replace the version in the spec file. Here the change is from .58 to .80
(5)Build the rpm using the .spc file as follows.
[root@test SPECS]# rpmbuild -ba kernel-xen.spec
The rpms will be available here(/root/rpmbuild/RPMS)
------------------------------------
[root@test rpmbuild]# ls RPMS/x86_64/
kernel-xen-3.4.80-1.x86_64.rpm kernel-xen-devel-3.4.80-1.x86_64.rpm kernel-xen-firmware-3.4.80-1.x86_64.rpm kernel-xen-headers-3.4.80-1.x86_64.rpm
[root@test rpmbuild]#
-------------------------------------
You can install the rpm using yum/rpm. here is the sample grub.conf after the installation.
[root@test ~]# cat /etc/grub.conf 
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd1,0)
# kernel /boot/vmlinuz-version ro root=/dev/sdb1
# initrd /boot/initrd-[generic-]version.img
#boot=/dev/sdc
default=0
timeout=5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.4.80-1.el6xen.x86_64)
root (hd1,0)
kernel /boot/vmlinuz-3.4.80-1.el6xen.x86_64 ro root=UUID=2e3c5488-2950-4143-ad6c-b522fc689685 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-3.4.80-1.el6xen.x86_64.img
title CentOS (2.6.32-431.5.1.el6.x86_64)
[root@test ~]# uname -r
3.4.80-1.el6xen.x86_64
[root@test ~]#s

Tuesday, December 31, 2013

Enable IPv6 on OpenVZ node


This page provides a guideline for setting up IPv6 on a CentOS 6.2 OpenVZ host node. We used SolusVM, but this guide is applicable to any deployment.

1) Check

/etc/sysctl.conf
It should contain the following:

net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv6.conf.all.proxy_ndp = 1
2) Check

/etc/sysconfig/network
It should contain the following:

NETWORKING=yes
HOSTNAME=eb1.evoboxes.org #Your Hostname goes here
GATEWAY=192.168.1.1 #Your IPv4 Gateway Goes here
NETWORKING_IPV6=yes
IPV6_DEFAULTGW="2001:123:123:1::ffff" #Your IPv6 Gateway goes here
IPV6FORWARDING=yes
3) Check

/etc/sysconfig/network-scripts/ifcfg-eth0
(or ethX depending on your configuration)

It should contain the following:

DEVICE="eth0"
BOOTPROTO="static"
BROADCAST="192.168.1.127" #Your Broadcast Address
DNS1="4.2.2.1"
GATEWAY="192.168.1.1" #Your IPv4 Gateway
HWADDR="00:25:90:55:3C:5A"
IPADDR="192.168.100.1" #Your IPv4 Address
NETMASK="255.255.255.0" #Your IPv6 Address
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPV6INIT="yes"
IPV6ADDR="2001:123:123:1::1" #Your IPv6 address, just use the first address from your prefix
IPV6_AUTOCONF=no
4)Run the following command:

cat /proc/sys/net/ipv6/conf/default/disable_ipv6
If the value is 0, you can skip to step 6.

5) If the value of the above command is 1: Run the following command:

echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6
6) Disable ip6tables to prevent any issues:

service ip6tables stop
chkconfig ip6tables off
7) Restart Networking:

service networking restart
Make sure you don’t see any errors

8) If you are using SolusVM, proceed to step 10.

9)Add IPv6 address to a VPS:

vzctl set <CTID> -ipadd <ipv6_addr> --save
Currently it seems that OpenVZ cannot add an address prefix, only a single address or /128.

10) If you followed step 9, skip this step. Add the IPv6 block in SolusVM: IP Blocks -> Add IPv6 Block Add IPv6 addresss to the block: IP Blocks -> List IP Blocks -> Manage Addresses and follow the directions Add the IPv6 addresses to the VPS: Virtual Servers -> List Virtual Servers -> Pick one -> IP’s -> Add Additional IPv6.

11) Login to the VPS and Test: SSH into the Host Node

vzctl enter <CTID>
ping6 ipv6.google.com
ping6 comcast6.net
12) Enjoy!