Solved

iptables question

Posted on 2009-05-19
3
294 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ubuntu VNC server rejects access by client 7 141
Lame BIND 9.3 10 58
iptables limit connection per ip correct way ? 2 87
Video Streaming 6 55
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now