Changes

Jump to: navigation, search

Virtual Ethernet device

1,019 bytes added, 00:21, 12 September 2009
Configure device and add route in CT0: adding script to automatize route creation + new subsection to make sure ipv4 forwarding is enabled in CT0
</pre>
You can automatize this at VPS creation by using a mount script <tt>$VEID.mount</tt>. The problem here is that the ''veth'' interface appears in CT0 '''after''' VPS has started, therefore we cannot directly use the commands in the mount script. We launch a shell script (enclosed by { }) in background (operator '''&''') that waits for the interface to be ready and then add the IP route. Contents of the mount script <tt>/etc/vz/conf/101.mount</tt>:<pre>#!/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 # Configure veth with IP after VPS has started{ IP=X.Y.Z.T DEV=veth101.0 while sleep 1; do /sbin/ifconfig $DEV 0 >/dev/null 2>&1 if [ $? -eq 0 ]; then /sbin/ip route add $IP dev $DEV break fi done} &</pre> ==== Make sure that you have IPv4 forwarding is enabled.in CT0 ==== 
<pre>
[host-node]# echo 1 > /proc/sys/net/ipv4/ip_forward
8
edits

Navigation menu