ramblings of an IT professional
OpenVZ
Allocate x IPs to OpenVZ VEs
May 2nd
I ran into an interesting issue today where we had a client migrating to us that needed us to allocated X IPs to each VPS on a node he had with us. X ranged from 1 IP to up to 12 per VE so I wrote a script that took three input files (one with available IPs [newips], one with VEIDs [veids], and one with the number of IPs each VEID was allocated [numips]) and doled out the IPs as needed. Here is the result:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash let r=1 let k=1 for i in `cat veids` do numips=$(sed -n "$k"p numips) for (( c=1; c<=$numips; c++ )) do ip=$(sed -n "$r"p newips) echo "Add $ip to $i" vzctl set $i --ipadd $ip --save let r=r+1 done let k=k+1 done |
Hopefully this will help any others who run into a similar issue.
Have a great day!
Common Issues – No Networking on new OpenVZ VPS
Mar 23rd
Hello all,
Today I ran into an interesting issue where a VPS had no networking either inbound or outbound after setup. This is the error that would present when restarting network via init.d:
Bringing up interface venet0: SIOCADDRT: Network is unreachable SIOCADDRT: Network is unreachable
This issue also presented in that cPanel licenses could not activate not could any ping or host commands work properly. I eventually narrowed down the issue to the fact that the IPs that had been added to the VPS were not properly set to ARP by checking with the following command (run on the node):
arp | grep [INSERT IP HERE]
In order to resolve this, all I needed to do was add the arp entries for the IPs on the actual virtual environment by running the following commands on the node:
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. This resolved the issue and all networking started working again properly.