Setting up a server behind a (effing) livebox
So the livebox is:
- in violation with the GPL (they use linux and don't release the code)
- a piece of sh*t that can't even do port forwarding correctly (i.e the dhcp server is buggy, no possibility to add static MAC addresses)
The solution
Use upnp (oh noes!) -> go get miniupnpc
The tool you'll want after the make command is done is upnpc-static, you don't need to make install that way.
Just copy that tool to /root/bin or change the path in the following script.
Here is the initscript i use on ubuntu to set up port forwarding to ssh and the ftpd:
#! /bin/sh
### BEGIN INIT INFO
# Provides: forwarding
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script that sets up forwarding for ssh, ftp and web external acces
# Description: Script that sets up forwarding for ssh, ftp and web external acces
### END INIT INFO
NAME=forwarding
DESCRIPTION="Script that sets up forwarding for ssh, ftp, munin and web external acces"
UPNPCMD=/root/bin/upnpc-static
# Exit if the package is not installed
test -x $CMD || exit 0
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting $DESCRIPTION" "$NAME"
CMD="$UPNPCMD -r 22 TCP 21 TCP 80 TCP 4949 TCP"
for port in $(seq 49152 49170); do
CMD="$CMD $port TCP"
done
$CMD 2>&1 > /dev/null
log_end_msg $?
return $?
}
do_stop () {
log_daemon_msg "Stopping $DESCRIPTION" "$NAME"
CMD="$UPNPCMD -d 22 TCP 21 TCP 80 TCP"
for port in $(seq 49152 49170); do
CMD="$CMD $port TCP"
done
$CMD 2>&1 > /dev/null
log_end_msg $?
return $?
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart|force-reload)
do_stop
do_start
;;
*)
log_success_msg "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
