Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting port forwarding without access to a router interface
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Yui
n00b
n00b


Joined: 21 Jul 2006
Posts: 29

PostPosted: Fri Jul 21, 2006 5:20 pm    Post subject: Setting port forwarding without access to a router interface Reply with quote

I don't have access to my router interface for insurance reason, so I can't reset the router and other things like that.
I need port forwarding (for amule, ssh, and some programs like that), I know that it's possible to create a port forwarding rule on a router without access to it. (Azureus can do it (I think they call it uPnP), and you have an interface to do that with WinXP).
All I want is a simple program that create a port forwarding rule on my router, in a terminal if possible. Redirect port 20 to 192.168.1.32 for example.

I began to look for that a long time ago and didn't find out yet how to do it. I'm a linux newbie, so I choosed to ask here before reading all azureus code to make a program that can do that.
My English is pretty bad, I hope you understand what I want.
Thanks


Last edited by Yui on Wed Jul 26, 2006 1:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dieter@be
Guru
Guru


Joined: 03 Apr 2005
Posts: 314
Location: Wetteren, Belgium

PostPosted: Fri Jul 21, 2006 5:25 pm    Post subject: Reply with quote

yep upnp that's it, i don't know exactly "how" to do it, but it's called "universal plug and play" so search on that :)
_________________
Nothing beats a ride on the Gentoo learning curve.
2 Gentoo Linux boxes - 2 Arch Linux boxes - Love all four
Say no to i386 binaries! -- Adopt an unanswered topic
Back to top
View user's profile Send private message
Suicidal
l33t
l33t


Joined: 30 Jul 2003
Posts: 959
Location: /dev/null

PostPosted: Fri Jul 21, 2006 5:34 pm    Post subject: Reply with quote

I just use the following, not using upnp but linuxbox 2 linuxbox:

Code:
#!/bin/bash
COMMAND="ssh -N -R 4596:localhost:22 foo.bar.com"
CHECK_TUNNEL=`ps -eo args | grep "$COMMAND" | grep -v grep`

if [ -z "$CHECK_TUNNEL" ] ; then
   $COMMAND
   fi


I set it to run every 5 min via crontab forwards port 22 on my local box to port 4596 on my home box.
Back to top
View user's profile Send private message
Yui
n00b
n00b


Joined: 21 Jul 2006
Posts: 29

PostPosted: Fri Jul 21, 2006 5:47 pm    Post subject: Reply with quote

If I understand you, foo.bar.com is the ip (or the dyndns stuff) of my modem-router ?
So the redirection is not actually done on the modem-router but it is my local box that "listen" on that port and catch the packets ?
Back to top
View user's profile Send private message
Suicidal
l33t
l33t


Joined: 30 Jul 2003
Posts: 959
Location: /dev/null

PostPosted: Fri Jul 21, 2006 9:49 pm    Post subject: Reply with quote

Yui wrote:
If I understand you, foo.bar.com is the ip (or the dyndns stuff) of my modem-router ?
So the redirection is not actually done on the modem-router but it is my local box that "listen" on that port and catch the packets ?


Correct either LHOST or RHOST in the following example can be a FQDN such as foo.bar.com or an IP such as 192.1.2.3


rewrote it a bit; (needed some clarification IMHO)

In this example the LHOST is forwarding port 22 to port 4596 on RHOST

LHOST="gentoo NSM box at work"
RHOST="home gentoo desktop"

LHOST:22---------------->RHOST:4596

The below script works best if you are using ssh keys.

Code:

#!/bin/bash
RHOST="foo.bar.com"
LHOST="localhost"
COMMAND="ssh -N -R 4596:$LHOST:22 $RHOST"
CHECK_TUNNEL=`ps -eo args | grep "$COMMAND" | grep -v grep`
 
if [ -z "$CHECK_TUNNEL" ] ; then
   $COMMAND
fi
Back to top
View user's profile Send private message
Dieter@be
Guru
Guru


Joined: 03 Apr 2005
Posts: 314
Location: Wetteren, Belgium

PostPosted: Sat Jul 22, 2006 9:41 am    Post subject: Reply with quote

if he doesn't have access to his router web-interface , he probably can't ssh to it either i think :)
_________________
Nothing beats a ride on the Gentoo learning curve.
2 Gentoo Linux boxes - 2 Arch Linux boxes - Love all four
Say no to i386 binaries! -- Adopt an unanswered topic
Back to top
View user's profile Send private message
Suicidal
l33t
l33t


Joined: 30 Jul 2003
Posts: 959
Location: /dev/null

PostPosted: Sat Jul 22, 2006 8:22 pm    Post subject: Reply with quote

Dieter@be wrote:
if he doesn't have access to his router web-interface , he probably can't ssh to it either i think :)


In my above example LHOST is behind a firewall that I cant configure RHOST is behind a firewall that I have access to. You will need access to at least one of the routers to make the port accessable. Most people at work dont have assess to the router but at home they usually do.
Back to top
View user's profile Send private message
Tin
Guru
Guru


Joined: 22 Dec 2005
Posts: 305
Location: Namur, Belgium

PostPosted: Sun Jul 23, 2006 11:45 am    Post subject: Reply with quote

I think that the router he spoke about is a modem with router inside, not a real machine.
Then, it is impossible that a ssh daemon runs on this box.
The router interface is a web interface provided by the modem itself, and permitting to do some nat and firewall configurations.
Because he is unable to have access to the interface (no password given by the provider because if you want the password, the guarantee is not valid anymore) BUT he noticed that some programs like azureus succeed in configuring some nat settings remotely (using the upnp he spoke about ?), he is trying to find HOW it is possible without having to read all the azureus sources.

Yui, don't you think it should be interesting to ask directly to the forum of azureus how they do that ?

Good luck :-)
_________________
Tin, the gentoobie
Back to top
View user's profile Send private message
Dieter@be
Guru
Guru


Joined: 03 Apr 2005
Posts: 314
Location: Wetteren, Belgium

PostPosted: Sun Jul 23, 2006 3:26 pm    Post subject: Reply with quote

Tin wrote:
Yui, don't you think it should be interesting to ask directly to the forum of azureus how they do that ?

universal plug & play :) (as he already said)

maybe have a look at the azureus code, maybe you'll see (references to) libraries that make the upnp magic possible :) (or ask the devs )
_________________
Nothing beats a ride on the Gentoo learning curve.
2 Gentoo Linux boxes - 2 Arch Linux boxes - Love all four
Say no to i386 binaries! -- Adopt an unanswered topic
Back to top
View user's profile Send private message
Yui
n00b
n00b


Joined: 21 Jul 2006
Posts: 29

PostPosted: Tue Jul 25, 2006 9:24 am    Post subject: Reply with quote

Well, I think your script would work for ssh and other programs like that. But I don't think it will work for programs like amule.
It's a good script and I could use it one day. But yeah, I'll read azureus source code and try to make a script for uPnP.
Thanks anyway :)
I'll post here if I find how to do it.
Back to top
View user's profile Send private message
Zi7
n00b
n00b


Joined: 23 Jul 2006
Posts: 43
Location: Provence

PostPosted: Tue Jul 25, 2006 11:36 am    Post subject: Reply with quote

There's a light upnp client library available here: http://miniupnp.free.fr/
You might want to give it a shot...
Good luck!
Back to top
View user's profile Send private message
Yui
n00b
n00b


Joined: 21 Jul 2006
Posts: 29

PostPosted: Wed Jul 26, 2006 1:42 pm    Post subject: Reply with quote

Yeah, it's exactly what I was seeking. I tried the Joao Paulo Barraca version (command line version of miniupnp) and it works even if it's quite difficult to use.
Thanks for all.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum