dennis henry

ramblings of an IT professional

Follow me on TwitterRSS Feeds

  • Home
  • About
  • Linux Tutorials
  • Code
  • Docs
  • Gallery

Allocate x IPs to OpenVZ VEs

May 2nd

Posted by dennis in Linux

No comments

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!

additions, bash, ip, OpenVZ

Common Issues – No Networking on new OpenVZ VPS

Mar 23rd

Posted by dennis in CentOS

No comments

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.

interface, Linux, network, networking, OpenVZ, resolv.conf, venet0
«12345»...Last »
    • Recent comments
    • Popular posts
    • Archives
    • Tags
    • Categories
    • Common Issues (7)
    • Linux (18)
      • Apache (1)
      • CentOS (4)
      • cPanel (9)
        • Easyapache (1)
      • Drives (1)
      • Exim (1)
      • IPTables (1)
      • MySQL (1)
      • Networking (2)
      • OpenSSH (1)
      • OpenVZ (4)
      • Subversion (1)
      • Xen (2)
    • PHP (2)
      • CakePHP (1)
      • GeSHI (1)
      • suPHP (1)
    3.4.3 5.x Apache assign ip addresses CakePHP centos Common Issues configuration connections cPanel cpuwatch demo Drives Easyapache exim ftp ftp accounts full GeSHI highlighting interface iptables ip usage libperl Linux memory usage mode MySQL network networking OpenVZ overwriting defaults password pcre perl preg_replace pure-ftpd resolv.conf subversion suPHP syntax upgrade venet0 xen yum
    • July 2011 (1)
    • June 2011 (1)
    • May 2011 (1)
    • March 2011 (1)
    • December 2010 (1)
    • November 2010 (2)
    • September 2010 (1)
    • August 2010 (2)
    • July 2010 (1)
    • April 2010 (2)
    • October 2009 (1)
    • June 2009 (1)
    • April 2009 (2)
    • March 2009 (3)
    • Install Xen 3.4.3 on CentOS 5.x (4)
    • CPUwatch (3)
    • Common Issues – Easyapache failing (2)
    • Total Memory on a Xen Node (2)
    • Common Issues – MySQL Connectivity Issues (1)
    • Simple IPTables OpenVZ Setup (1)
    • Common Issues – Hostname A Record (0)
    • Common Issues – Main Drive Full (Mounting Issues) (0)
    • Allocate x IPs to OpenVZ VEs (0)
    • Common Issues – Maxed out Apache Connections (0)
    • dennis: I'm glad to hear my script could help you! Xen's memory management is indeed odd but, overall, I...
    • Sam: I too was caught out by the Xen hypervisor's method of memory management. The Dom-0 machine is...
    • dennis: CPUWatch completely pauses processes until the load decreases, so its not ideal for services like...
    • victor: I've read several sites that talk about cpuwatch where they use the word Pause or throttled. ...
    • dennis: Hey Ben! Thanks for the comment. That's odd it didn't work for you. I've used this same method...
    • Ben: This did not work as per below: cpan> install Acme::Spork CPAN: Storable loaded ok...
    • dennis: Thanks Jimmy! Glad you enjoyed it.
    • jimmy: finally an upgrade guide that just "works" thanks
  • My latest tweets

    Loading tweets...
    Follow me on Twitter!
  • User Login






    • Lost your password?
RSS Feeds XHTML 1.1 Top