LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-24-2015, 05:55 AM   #1
arjunlaura
LQ Newbie
 
Registered: Jan 2015
Posts: 1

Rep: Reputation: Disabled
Port Forwarding To Local IP


Hey guys!
This is my first thread so feeling really excited!!

So my question is i have a dynamic external ip and i'm just tryin to access my local server on my laptop from internet via my external ip...
But i'm not able to port forwrd it.

I even tried:

iptables -t nat -A PREROUTING -d 192.168.1.1 -j DNAT --to-destination 192.168.1.x on my router via telnet...

I make sure that i do not reboot my router(since its dynamic and it will change)

Any suggestions

Last edited by arjunlaura; 01-24-2015 at 05:56 AM.
 
Old 01-24-2015, 09:23 AM   #2
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
If I understand you right, you're attempting to connect to your server through your laptop via telnet?

This is a very very very bad idea. telnet is not secure.

Use ssh.

To port forward a remote port to a local port:

Code:
ssh -NR remoteip:remoteport:localip:localport hostname
The -N doesn't grab a shell or send a command (good for forwarding ports)
-R indicates a reverse port (i.e. remote to local port instead of local to remote)

You will need port 22 open on the server if connecting via external ip.
Note that the other ports will not need to be open. If you bind 9876 on the remote host to 7000 on the local ip, you still only need port 22 open.
It is a wise idea to use public key auth - especially on any external network.

You can use Match Statements to fine tune what people can do who connect. You can configure it in /etc/ssh/sshd_config

Ensure AllowTcpForwarding is set to yes to enable port forwarding
I'm pretty sure it defaults to yes if not specified though.

Last edited by Miati; 01-24-2015 at 09:34 AM.
 
Old 01-24-2015, 09:47 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,740

Rep: Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923
Welcome to LinuxQuestions.

What is the make/model of your router? Typically 192.168.1.1 would be the LAN address of the router and not its external address. How do you want to access the server? What do you want to accomplish? i.e. remote desktop etc.

My understanding is the OP is using telnet to access the router.

Last edited by michaelk; 01-24-2015 at 09:49 AM.
 
Old 01-25-2015, 05:43 AM   #4
zafar_dandoti
Member
 
Registered: Dec 2005
Location: India
Distribution: centos
Posts: 178

Rep: Reputation: 13
first upon u need a static ip from ISP
using dynamic external ip u cannot connect to ur server.
Else u can use dyndns or noip subscription to acheive ur goal. Also need to forward appropriate port in the router/modem.

Last edited by zafar_dandoti; 01-25-2015 at 05:46 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CentO 6: Apache access works from local network but port forwarding fails kenneth_phough Linux - Server 3 06-17-2013 10:37 AM
C coding: Hacking ssh: dynamic local port forwarding implementation? Web31337 Programming 2 02-03-2010 06:05 AM
Problem with SSH local port forwarding suhas! Linux - Security 3 07-25-2007 10:06 AM
Local Port Forwarding CobraCRK Linux - Server 3 05-14-2007 03:13 PM
forwarding a local port Hano Linux - Networking 8 10-14-2003 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration