Solved

iptables question

Posted on 2009-05-19
3
313 Views
Last Modified: 2012-05-07
Hello everybody!
I have a linux firewall (192.168.0.1) and I would like to forward all the incoming ssh connection from LAN directed to FIREWALL IP (1.2.3.4) to a LAN machine (192.168.0.10).

Do you think it is possible? How can I do it?
0
Comment
Question by:phoenix128
3 Comments
 
LVL 11

Expert Comment

by:climbgunks
ID: 24428674

It's been a while...

change to use the correct interface:

iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 22 -j DNAT --to 192.168.0.10:22
iptables -A INPUT -p tcp -m state --state NEW --dport 22 -i eth1 -j ACCEPT
0
 

Author Comment

by:phoenix128
ID: 24429742
It is not soe easy :)
I also need to masquerade the packet to let the internal machine believe it is coming from the firewall's IP.

The problem is that I already tried to do it with DNAT and MAQUERADE or SNAT... the packet is sent to the destination's machine but it does not come back.

Any idea?
0
 
LVL 7

Accepted Solution

by:
diepes earned 500 total points
ID: 24434389
1. I assume you can ping the ip's from the fw ? (Connectivity ok)
2. What is your interface names ?  eth0-192.168.0.1   eth1-1.2.3.4
3. Subnet mask's ?

from climbgunks:
iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 22 -j DNAT  --to-destination192.168.0.10:22

iptables -A POSTROUTING -t nat -o eth0 -p tcp --dport 22 -j SNAT --to-source 192.168.0.1

iptables -A FORWARD -p tcp --dport 22 -d 192.168.0.10

The last rule you can make more specific if you know where the ssh will come from.
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
E-mail settings for Fail2ban 7 139
installed old nagios.... 13 152
App holding yum lock unable to update my rpm package 1 72
VPS for routing recomendations 3 64
I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question