<div dir="ltr">Hi all,<br>In order to run upnp and avahi over a cellular internet connection (3G) I am running openvpn in bridging mode.<br>After I establish a connection device , tap0, I issue a dhcp request.<br>to do this I have added a --up script option to openvpn arguments.<br>
here is the script :<br><br><div class="text" style="font-family: monospace;"><ol><li class="li1"><div class="de1">cat /etc/init.d/udhcpc</div></li><li class="li2"><div class="de2">#!/bin/sh</div></li><li class="li1"><div class="de1">
#</div></li><li class="li2"><div class="de2"># openvpn custom dhcp cilient Start and stop </div></li><li class="li1"><div class="de1">#</div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1">
#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin </div></li><li class="li2"><div class="de2">DAEMON=/sbin/udhcpc </div></li><li class="li1"><div class="de1">
NAME=udhcpc </div></li><li class="li2"><div class="de2">DESC="Openvpn dhcp client" </div></li><li class="li1">
<div class="de1"># $2 is passed by openvpn with the device created ie tap0</div></li><li class="li2"><div class="de2">SCRIPT=/etc/openvpn/udhcp.script</div></li><li class="li1"><div class="de1">PIDFILE=/var/run/$NAME.$DEVICE.pid </div>
</li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1">test -x $DAEMON || test -x $SCRIPT || exit 0</div></li><li class="li2"><div class="de2">if [ -z "$2" ] ; then</div></li><li class="li1">
<div class="de1"> DEVICE=tap0</div></li><li class="li2"><div class="de2">else</div></li><li class="li1"><div class="de1"> DEVICE=$2</div></li><li class="li2"><div class="de2">fi</div></li><li class="li1"><div class="de1">
# --now Exit with failure if a lease cannot be obtained. </div></li><li class="li2"><div class="de2">if [ -z "$DAEMON_OPTS" ] ; then</div></li><li class="li1"><div class="de1"> DAEMON_OPTS="--now --no-zeroconf -i $DEVICE -s $SCRIPT --pidfile=$PIDFILE"</div>
</li><li class="li2"><div class="de2">fi</div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2">set -e</div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2">
case "$1" in</div></li><li class="li1"><div class="de1"> start)</div></li><li class="li2"><div class="de2"> echo -n "Starting $DESC for $DEVICE: "</div></li><li class="li1"><div class="de1"> echo " params: $DAEMON_OPTS "</div>
</li><li class="li2"><div class="de2"> while [ ! -d /sys/class/net/$DEVICE ] ; do</div></li><li class="li1"><div class="de1"> echo " $DEVICE missing so can't issue dhcp req" </div></li>
<li class="li2"><div class="de2"> sleep 2</div></li><li class="li1"><div class="de1"> done</div></li><li class="li2"><div class="de2"> ifconfig $DEVICE</div></li><li class="li1"><div class="de1">
echo " going to req dhcp for `cat /sys/class/net/$DEVICE/address`"</div></li><li class="li2"><div class="de2"> $DAEMON $DAEMON_OPTS</div></li><li class="li1"><div class="de1"> while [ $? -ne 0 ] ; do</div>
</li><li class="li2"><div class="de2"> echo sleepNow</div></li><li class="li1"><div class="de1"> sleep 2</div></li><li class="li2"><div class="de2"> $DAEMON $DAEMON_OPTS</div></li>
<li class="li1"><div class="de1"> done</div></li><li class="li2"><div class="de2"> echo "$NAME." </div></li><li class="li1"><div class="de1"> ;; </div>
</li><li class="li2"><div class="de2"> starts)</div></li><li class="li1"><div class="de1"> start-stop-daemon --start \</div></li><li class="li2"><div class="de2"> --pidfile /var/run/$NAME.$DEVICE.pid \</div>
</li><li class="li1"><div class="de1"> --exec $DAEMON -- $DAEMON_OPTS</div></li><li class="li2"><div class="de2"> echo "$NAME." </div></li><li class="li1"><div class="de1"> ;;</div>
</li><li class="li2"><div class="de2"> stop)</div></li><li class="li1"><div class="de1"> echo -n "Stopping $DESC: "</div></li><li class="li2"><div class="de2"> kill `cat $PIDFILE` || true</div></li>
<li class="li1"><div class="de1"> /bin/rm $PIDFILE</div></li><li class="li2"><div class="de2"> echo "$NAME."</div></li><li class="li1"><div class="de1"> ;;</div></li><li class="li2"><div class="de2">
stops)</div></li><li class="li1"><div class="de1"> echo -n "Stopping $DESC: "</div></li><li class="li2"><div class="de2"> start-stop-daemon --stop --quiet \</div></li><li class="li1"><div class="de1">
--pidfile /var/run/$NAME.$DEVICE.pid \</div></li><li class="li2"><div class="de2"> --exec $DAEMON</div></li><li class="li1"><div class="de1"> echo "$NAME."</div></li><li class="li2">
<div class="de2"> ;;</div></li><li class="li1"><div class="de1"> reload|restart|force-reload)</div></li><li class="li2"><div class="de2"> #</div></li><li class="li1"><div class="de1"> # If the "reload" option is implemented, move the "force-reload"</div>
</li><li class="li2"><div class="de2"> # option to the "reload" entry above. If not, "force-reload" is</div></li><li class="li1"><div class="de1"> # just the same as "restart".</div>
</li><li class="li2"><div class="de2"> #</div></li><li class="li1"><div class="de1"> echo -n "Restarting $DESC: "</div></li><li class="li2"><div class="de2"> start-stop-daemon --stop --quiet --pidfile \</div>
</li><li class="li1"><div class="de1"> /var/run/$NAME.$DEVICE.pid --exec $DAEMON</div></li><li class="li2"><div class="de2"> sleep 1</div></li><li class="li1"><div class="de1"> start-stop-daemon --start --quiet \</div>
</li><li class="li2"><div class="de2"> --pidfile /var/run/$NAME.$DEVICE.pid \</div></li><li class="li1"><div class="de1"> --background --make-pidfile \</div></li><li class="li2"><div class="de2"> --exec $DAEMON -- $DAEMON_OPTS</div>
</li><li class="li1"><div class="de1"> echo "$NAME."</div></li><li class="li2"><div class="de2"> ;;</div></li><li class="li1"><div class="de1"> *)</div></li><li class="li2"><div class="de2"> N=/etc/init.d/$NAME</div>
</li><li class="li1"><div class="de1"> # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2</div></li><li class="li2"><div class="de2"> echo "Usage: $N {start|stop|restart|force-reload}" >&2</div>
</li><li class="li1"><div class="de1"> exit 1</div></li><li class="li2"><div class="de2"> ;;</div></li><li class="li1"><div class="de1">esac</div></li><li class="li2"><div class="de2"> </div></li><li class="li1">
<div class="de1">exit 0</div></li></ol></div><br><br><br><br><br>and the output:<br><div class="text" style="font-family: monospace;"><ol><li class="li1"><div class="de1">Tue Mar 23 10:03:11 2010 TUN/TAP device tap0 opened</div>
</li><li class="li2"><div class="de2">Tue Mar 23 10:03:11 2010 TUN/TAP TX queue length set to 100</div></li><li class="li1"><div class="de1">Tue Mar 23 10:03:11 2010 /etc/init.d/udhcpc start tap0 1500 1574 init</div></li>
<li class="li2"><div class="de2">Starting Openvpn dhcp client for tap0:
params: --now --no-zeroconf -i tap0 -s /etc/openvpn/udhcp.script
--pidfile=/var/run/udhcpc..pid </div></li><li class="li1"><div class="de1">tap0 Link encap:Ethernet HWaddr FE:3D:5B:EB:B1:7B </div></li><li class="li2"><div class="de2"> BROADCAST MULTICAST MTU:1500 Metric:1</div>
</li><li class="li1"><div class="de1"> RX packets:0 errors:0 dropped:0 overruns:0 frame:0</div></li><li class="li2"><div class="de2"> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0</div></li><li class="li1">
<div class="de1"> collisions:0 txqueuelen:100 </div></li><li class="li2"><div class="de2"> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)</div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2">
going to req dhcp for fe:3d:5b:eb:b1:7b</div></li><li class="li1"><div class="de1">udhcpc (v0.9.9-pre) started</div></li><li class="li2"><div class="de2">Sending discover...</div></li><li class="li1"><div class="de1">Sending discover...</div>
</li><li class="li2"><div class="de2">Sending discover...</div></li><li class="li1"><div class="de1">Sending discover...</div></li><li class="li2"><div class="de2">No lease, failing.</div></li><li class="li1"><div class="de1">
Tue Mar 23 10:03:24 2010 script failed: external program exited with error status: 1</div></li><li class="li2"><div class="de2">Tue Mar 23 10:03:24 2010 Exiting</div></li></ol><br>so as you see it doesnt work.<br>can I use icd to solve this?<br>
</div><br><br></div>