4
edits
Changes
→Adding an external script to VE0
Follow Option A and add in addition a VETH_IP_ADDRESS="<your VE IP>" entry to your /etc/vz/conf/VEID.conf including the IP Address you want to set.
==== Adding an external script to VE0 ====Copy and paste the following code (either Option A or B) into /usr/sbin/vznetaddroute:=====Option A)=====
<pre>
#!/bin/bash
Add one elsif-section for every veth-enabled VE you'd like to have automatically configured. Remember to run <pre>chmod +x /usr/sbin/vznetaddroute</pre> to make the script executable.
=====Option B)=====
<pre>
#!/bin/bash
VZCONFDIR=/etc/vz
VZHOSTIF=$BASH_ARGV
. $VZCONFDIR/conf/$VEID.conf
if [ -n $VETH_IP_ADDRESS ]; then
echo "Adding interface $VZHOSTIF and route $VETH_IP_ADDRESS for VE$VEID to VE0"
/sbin/ifconfig $VZHOSTIF 0
echo 1 > /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding
/sbin/ip route add $VETH_IP_ADDRESS dev $VZHOSTIF
else
echo "found no VETH_IP_ADDRESS in $VZCONFDIR/conf/$VEID.conf!"
exit 1;
fi
exit
</pre>
Remember to run <pre>chmod +x /usr/sbin/vznetaddroute</pre> to make the script executable.
====Make vzctl run the script====
To make vzctl run the script, copy and paste the following line to /etc/vz/vznet.conf: