Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: Yann Nottara on February 17, 2001, 07:26:57 AM
-
I need to forward some ports from my E-smith gateway to an internal server using ipmasqasm. While searching through posts on the forum, I found this very informative link about the use of ipmasqadm with a dynamic IP:
http://www.linux.org/docs/ldp/howto/mini/IPMasquerading+Napster-5.html
As my external interface is connected to the Net via ADSL (PPPoE) with a dynamic IP address, the script I'm interested in is :
#!/bin/sh
ppp_ip="/sbin/ifconfig ppp0 | grep 'inet addr' | awk '{print $2}' | sed -e
's/.*://'"
/usr/sbin/ipmasqadm portfw -f
/usr/sbin/ipmasqadm portfw -a -P tcp -L ${ppp_ip} 20 -R 192.168.0.2 20
/usr/sbin/ipmasqadm portfw -a -P tcp -L ${ppp_ip} 21 -R 192.168.0.2 21
My question is : Is such a script directly usable in E-smith 4.1 & if yes, in which template should I put it (I'm considering /etc/e-smith/templates/etc/ppp/ip-up.local/signal-event) ?
And what would be the "cleanest" way to insert it ?
If that's not appropriate, could you suggest any other option ?
Thanks in advance for any help !
-
Answering to myself & if anyone interested, here's what I found in the E-smith Devloper mailing-list :
devinfo-subscribe@lists.e-smith.org
infos here : http://www.e-smith.org/content/developers/
Subject:
[e-smith-devinfo] RE: Additional Webserver behind gateway
Date:
Wed, 28 Feb 2001 15:51:04 -0800
From:
Dan B
To:
David Boccabella
CC:
devinfo@lists.e-smith.org
Everytime your ip address changes, you need to run the following
script. If you are on ppp, then put this in the bottom of your
/etc/sysconfig/network-scripts/ifup-post, if you are on some DSL/cable
DHCP, then that *might* not work for you (does anyone know of a script that
dhcpcd execs after every new ip addy?).
#this should calculate your ip address from ifconfig
#or you can use EXTIP=$IPADDR if it is in ifup-post
#EXTIP=$IPADDR
EXTIP=ifconfig ${DEVICE} | grep 'inet addr' |
awk -F: '{ print $2 } ' | awk '{ print $1 }'
eval /bin/ipcalc --silent --hostname ${IPADDR} && set_hostname $HOSTNAME
INTIP=10.0.0.65
ipmasqadm portfw -f
ipmasqadm portfw -a -P tcp -L $EXTIP 80 -R $INTIP 80
Maybe this will help someone else / or others on the list will have comments.
Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com
And now the reply from Gordon Rowell
On Wed, Feb 28, 2001 at 03:51:04PM -0800, Dan B wrote:
> [...]
> Everytime your ip address changes, you need to run the following
> script. If you are on ppp, then put this in the bottom of your
> /etc/sysconfig/network-scripts/ifup-post, if you are on some DSL/cable
> DHCP, then that *might* not work for you (does anyone know of a script that
> dhcpcd execs after every new ip addy?).
The {interface}.exe files in /etc/dhcpcd/ and e-smith then calls the
ip-change event. You don't need to touch anything in /etc/dhcpd - we've
already done that for you.
> [...]
> Maybe this will help someone else / or others on the list will have comments.
Why are you doing it the hard way? :-)
The scripts in /etc/e-smith/events/ip-change are called when your external
IP changes. No calculation required. The new external IP can be retrieved
with
/sbin/e-smith/config get ExternalIP
in shell. There are plenty of Perl examples in that directory to show you
how to get direct access to the config database.
Gordon