logIt Log Around The Clock

Startup script for TAP interfaces

To add startup script we can use:

I added the following shell script: setup-tap:

#! /bin/bash
tap_up() {
tunctl -t tap0 -u $USER
tunctl -t tap1 -u $USER
ifconfig tap0
ifconfig tap1
#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1
tap_down() {
tunctl -d tap0
tunctl -d tap1
sysctl -w net.ipv4.ip_forward=0
case "$1" in
echo "Usage: $0 {start|stop}"
exit 0

Basically it is used as ./setup-tap start|stop. The following steps add it to boot:
copy it to /etc/init.d/setup-tap
chmod +xr setup-tap
update-rc.d setup-tap defaults

The last updating will put it in default runlevel:
setup-tap start in runlevel 2,3,4, and 5 setup-tap stop in runlevel 1 and 6.

Specific to this script itself, it didn’t run at first due to the $USER environment variable which must be set to arif (my username).

One thought on “Startup script for TAP interfaces

  1. Arif

    Removing example:
    $ sudo update-rc.d -f smstools remove
    Removing any system startup links for /etc/init.d/smstools ...

    It will remove the file as well from init.d

Leave a Reply