OpenVZ Forum


Home » General » Support » Network settings - differnet address range for containers
Re: Network settings - differnet address range for containers [message #43232 is a reply to message #43195] Wed, 10 August 2011 06:26 Go to previous messageGo to previous message
naro is currently offline  naro
Messages: 4
Registered: March 2011
Junior Member
Please replace 11.22.33 with your own common part of IP address range. This is just raw string comparsion so no subnet checking etc.

There is one problem I did not solve yet. The ARP cache. If you move VPS to another hardware node, you must wait about 10 minutes until ARP cache on the gateway is cleared. The gateway is not under my control so I can't clear the cache manually Sad

File: /etc/vz/conf/vps.mount
#!/bin/bash

# This script source VPS configuration files in the same
# order as vzctl does
# if one of these files does not exist then something is
# really broken

[ -f /etc/vz/vz.conf ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

# source both files. Note the order, it is important
. /etc/vz/vz.conf
. $VE_CONFFILE

if [ -z "$IP_ADDRESS" ] 
then
   # no IP for this container
   echo "No IP address for this container"
   exit 0
fi

for IP in $IP_ADDRESS
do
    if `echo $IP | grep "11.22.33" 1>/dev/null 2>&1`
    then
       # this container uses our IP address range. Check ARP 
       if `arp -n | grep $IP 1>/dev/null 2>&1`
       then 
           # command above return 1 if item is not found 
           echo "$IP is already in ARP table. Weird."
       else 
           # IP is not in local ARP table. Add. it
           echo "Adding $IP to ARP table"
           arp -i eth0 -Ds $IP eth0 pub
       fi
    fi
done

exit 0



File: /etc/vz/conf/vps.umount
#!/bin/bash

# This script source VPS configuration files in the same
# order as vzctl does
# if one of these files does not exist then something is
# really broken

[ -f /etc/vz/vz.conf ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

# source both files. Note the order, it is important
. /etc/vz/vz.conf
. $VE_CONFFILE

if [ -z "$IP_ADDRESS" ] 
then
   # no IP for this container
   echo "No IP address for this container"
   exit 0
fi

for IP in $IP_ADDRESS
do
    if `echo $IP | grep "11.22.33" 1>/dev/null 2>&1`
    then
       # this container uses our IP address. Check ARP 
       if `arp -n | grep $IP 1>/dev/null 2>&1`
       then 
           # IP is in local ARP table. Remove it
           echo "Removing $IP from ARP table"
           arp -i eth0 -d $IP 
       else 
           echo "$IP is not in ARP table. Weird."
       fi
    fi
done

exit 0
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: are vzdump problems well known ?
Next Topic: Container ebtables LOG are going to Hardware Node CT0 syslog
Goto Forum:
  


Current Time: Fri Jul 25 23:27:09 GMT 2025

Total time taken to generate the page: 0.29541 seconds