LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-2024, 10:41 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,612

Rep: Reputation: 180Reputation: 180
iptables cannot port forward


I've done this successfully in the past, but am unable get it right now. I want connections to port 1912 on host MAIL to forward to port 3389 on IP 192.168.0.62. Verify I could get to that host: port from another LAN host, I first ran 'nc -vl -p 1912 localhost' on host MAIL, then telnet'ed to that port from another host on the LAN. That worked. I then tried:
Code:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 1912 -j DNAT --to-destination 192.168.0.62:3389
When I then tried telnet'ing to MAIL port 1912 from another host, no connection.

Keeping the above setting, I added:
Code:
iptables -A FORWARD -i eth0 -d 192.168.0.62 -p tcp --dport 3389 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 192.168.0.62 -p tcp --dport 3389 -j SNAT --to-source 192.168.0.2
iptables -t nat -A POSTROUTING -o eth0 -d 192.168.0.62 -p tcp --dport 3389 -j SNAT --to-source 192.168.0.2
I had these setting in my notes from a previous successful connection from long ago, but again, I could not connect to MAIL:1912 from another host.

Obviously, I'm doing something wrong. Can someone straighten me out?

Last edited by mfoley; 01-24-2024 at 10:49 PM.
 
Old 01-24-2024, 11:01 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,767

Rep: Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765
Did you turn on port forwarding in the kernel by setting net.ipv4.ip_forward ???
 
1 members found this post helpful.
Old 01-25-2024, 12:59 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,612

Original Poster
Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by wpeckham View Post
Did you turn on port forwarding in the kernel by setting net.ipv4.ip_forward ???
Duh! No! I did not. This is a scratch install of Linux and I just forgot. It's working now. Thanks.
 
  


Reply

Tags
port forwarding



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
Closed Port/Port in use when attempting to port forward for server. Tetrad Linux - Networking 2 07-06-2015 11:54 AM
[SOLVED] iptables port forward not working for port range mapping to anohter Port range in Linux 2.6.39 kinghong66 Linux - Networking 2 06-17-2015 07:17 PM
Iptables can't port forward (PAT Port address translation) sfrederiksen Linux - Networking 7 12-20-2011 10:47 AM
If I forward a port in iptables, does the port have to be open on the firewall? qwertyjjj Linux - Server 4 08-06-2009 09:22 AM
How can I forward ports with IPtables? I want to forward 80 to 8080 abefroman Linux - Networking 3 05-23-2008 10:05 AM

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

All times are GMT -5. The time now is 07:41 PM.

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