Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I think this is extremely simple but I'm stuck.
I have a direct connection to the internet and a private network.
I have to enter one of the computers in the private network from the internet.
This computer is a linux box with openssh listening in port 22. (ip 192.168.5.2)
So I have another box with two network boards, one connected to the internet (ip xx.xx.xx.xx) and another conected to my internal network (192.168.5.37)
in this box every port is closed as read with netstat.
So far I've wrote:
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.xx --dport 22 -j DNAT --to 192.168.5.2:22
iptables -A FORWARD -p tcp -d 192.168.5.2 --dport 22 -j ACCEPT
but nothing happens, (I am trying to enter from my Windows box using Putty, using xx.xx.xx.xx port 22 as the IP)
Please help me, I'm here working on Jan 1 because this has to be ready for tomorrow.
Thanks and happy 2004 for you all.
I'm not sure if you need :22 with --to when the port is gived by --dport. Here's part of my firewall (port 5555 is freeciv, btw)
I think that EXTIF and EXTIP are easy to understand.
Thanks for your quick answers
g-rod: no, this is a box I set up just for this purpose. Should I?
Mara: I rewrote the iptables commands just as yours but nothing happens.
iptables -t nat -L -v shows that there are packages entering through that chain.
In theory there is nothing more to do, is there?
Yes you need to translate the source address as the packets go back out.
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE;
or
iptables -t nat -I POSTROUTING -s 192.168.5.2 -o eth0 -j SNAT --to-source <public ip>;
The first way NATS all private ips to the ip of the firewall. The second one maps only the ssh machine to a uniwue public address. I think you want the second one. I am assuming the eth0 is your external facing nic.
ĄSOLVED!
Also I had to add the gateway to the internal machine! (thanks to another question in this forum)
Well, thanks again and a happy new year for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.