Monday 3 December 2012

How To Add Private IP in OpenVZ VPS


First we need to configure a private IP and its route in VPS Node and ensure that private network is available on Node. Then follow the steps below.

1) Add private IP to VPS.

 vzctl set <VEID> --ipadd <private IP> --save
 Eg:
 vzctl set 100 --ipadd 10.10.11.5 --save

2) Add routing rules as follows.

 ip ro add <private network range> via <gateway of private IP>
 Eg:
 ip ro add 10.10.0.0/16 via 10.10.11.5

Here we are using the VEs own private IP as the gw to work the private IP in VPS, no need to use its original gateway(like 10.10.11.1), it wont work.