LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2008, 12:37 PM   #1
manuelafl
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Rep: Reputation: 0
SSH Redirection


How could I redirect the access through my ssh port?

I wrote a rule like this one, but it's not working.

Code:
iptables -A FORWARD -p tcp -i eth0 --dport 22022 -d 192.168.0.1 -j ACCEPT
iptables -A FORWARD -p udp -i eth0 --dport 22022 -d 192.168.0.1 -j ACCEPT

iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 --dport 22022 -i eth0 -j DNAT --to
 192.168.0.1:22
iptables -t nat -A PREROUTING -p udp -d 192.168.0.1 --dport 22022 -i eth0 -j DNAT --to
 192.168.0.1:22
What could I do to get this working properly?

Thankss

Last edited by manuelafl; 02-28-2008 at 12:38 PM.
 
Old 02-28-2008, 02:28 PM   #2
mtimbro
Member
 
Registered: Feb 2008
Location: Montreal, Canada
Distribution: RedHat 3/4, Ubuntu 7.10
Posts: 86

Rep: Reputation: 15
Quote:
Originally Posted by manuelafl View Post
How could I redirect the access through my ssh port?

I wrote a rule like this one, but it's not working.

Code:
iptables -A FORWARD -p tcp -i eth0 --dport 22022 -d 192.168.0.1 -j ACCEPT
iptables -A FORWARD -p udp -i eth0 --dport 22022 -d 192.168.0.1 -j ACCEPT

iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 --dport 22022 -i eth0 -j DNAT --to
 192.168.0.1:22
iptables -t nat -A PREROUTING -p udp -d 192.168.0.1 --dport 22022 -i eth0 -j DNAT --to
 192.168.0.1:22
What could I do to get this working properly?

Thankss
I have a couple of things that I could suggest:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22022 -j DNAT --to 192.168.1.50:22
iptables -A INPUT -p tcp -m state --state NEW --dport 22022 -i eth0 -j ACCEPT

-Your 'prerouting' statement should be first.
-I'd use the input chain.
-I'd use the '-m state' switch.
-No need for udp.

Let me know if it helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 03:50 AM
I/O redirection jittinan2 Linux - Newbie 7 08-21-2007 09:01 PM
redirection bhuvana Linux - General 2 07-03-2006 03:36 AM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 01:34 PM
redirection in C pantera Programming 2 08-11-2004 02:06 PM


All times are GMT -5. The time now is 10:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration