/* HINT: Search archives @ http://www.indyramp.com/masq/ before posting! */


Scott Savarese <[EMAIL PROTECTED]> wrote:
>
> I have a local lan consisting of a laptop and a desktop.  The laptop's
> IP address is unknown to the rest of the world.  The desktop serves as
> a router and does the masquerading between the lan and the internet
> (through a dynamically allocated PPP address).

This is a very typical masq setup.

> I want to be able to telnet (ssh) to the laptop directly from the
> internet without having to connect to the desktop first...

This is a very typical use of port-forwarding.

> I was thinking about mapping the ports on the desktop so that if I
> telnet to port 12345 (or some other unused port) on the desktop, the
> desktop would route it directly to a port on the laptop.

You did not include any kernel version info, so I will assume you are
using Linux 2.2, and ipchains.  This setup uses the "ipmasqadm" tool to
make use of port-forwarding.  I don't know if any Linux distributions
include this tool by default, so you may have to download and compile
it, from

    http://juanjox.kernelnotes.org/#ipmasqadm

Once you have it set up, a command line such as this should do what you
want:

    ipmasqadm portfw -a -P tcp -L <extern-ip> 12345 -R <laptop> 22

This will forward incoming connections on port 12345, from the external
network, to your laptop machine, on port 22 (the ssh port).  You would
use a command like "ssh -p 12345 <desktopmachine>" to talk to your
desktop machine using that port number, and it will end up contacting
the laptop.  You should give the laptop's hostname in place of <laptop>.

Now, there some complications because of your setup.  One is that you
have a dynamic IP address.  This means that, each time your desktop
machine dials out, it must flush and re-instate the forwarding rules,
with the correct IP address.

The easiest way that I know to do this, is to use the /etc/ppp/ip-up
script, which is normally run every time a PPP connection is made.  The
IP address is fed to this script, and it runs as root, so you can do all
sorts of network configuration from here.  This is a simple one:

    #!/bin/sh

    # /etc/ppp/ip-up script, which sets up forwarding to the laptop

    ipmasqadm portfw -f
    ipmasqadm portfw -a -P tcp -L $4 12345 -R <laptop>  # $4 param is IP#

The next complication is that, since your IP is dynamic, you won't know
what address to "ssh" to, in order to contact your laptop.  There are
ways to solve that problem, such as registering with "dynip.com" or
"tzo.com" or some other dynamic DNS service.  But those issues are a bit
more complicated, and you might already have some way to tell what your
address is.

Another complication is that, your dialup system might be offline when
you want to connect to it.  I don't know how to fix that problem, though
of course there are ways..  :)

-- 
   [EMAIL PROTECTED] (Fuzzy Fox)      || "Good judgment comes from experience.
sometimes known as David DeSimone  ||  Experience comes from bad judgment."
  http://www.dallas.net/~fox/      ||                 -- Life Lessons

_______________________________________________
Masq maillist  -  [EMAIL PROTECTED]
Admin requests can be handled at http://www.indyramp.com/masq-list/ -- THIS INCLUDES 
UNSUBSCRIBING!
or email to [EMAIL PROTECTED]

PLEASE read the HOWTO and search the archives before posting.
You can start your search at http://www.indyramp.com/masq/
Please keep general linux/unix/pc/internet questions off the list.

Reply via email to