[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Port Forwarding with iptables

Posted on 2013-11-26
6
Medium Priority
?
490 Views
Last Modified: 2013-11-27
I am a newbie with iptables.
I want to have all incoming traffic on port x redirect to internal ip address 192.168.136.55 on the same port x.
I have tried several syntaxes but they don't work.
Can you help me with the syntax for this please?
0
Comment
Question by:LostInWindows
  • 4
  • 2
6 Comments
 
LVL 23

Expert Comment

by:savone
ID: 39679688
You do not "forward" a port on iptables like you would on a netgear firewall.

If you have a service, let's say http (web server) running on port 80, you only need to open the port or allow traffic on that port like so:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

That will allow traffic on port 80 through to your web server.
0
 
LVL 1

Author Comment

by:LostInWindows
ID: 39679732
The Linux server is running as a firewall and mail server. That is why they are running iptables.
Can I forward port 3389 to my Windows machine so that I can Remote Desktop?
0
 
LVL 23

Accepted Solution

by:
savone earned 2000 total points
ID: 39679767
iptables -t nat -A PREROUTING -p tcp -d <linux server ip> --dport 3389 -j DNAT --to-destination <windows ip>:3389
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Author Comment

by:LostInWindows
ID: 39679826
I now have this entry in iptables:
iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 -dport 3389 -j DNAT --to-destination 192.168.0.55:3389
I restarted the Linux server because I didn't know if I had to refresh what is in the kernel.
I cannot reach the Windows server. I have checked to ensure the Windows server is accepting 3389.
Did I miss something?
0
 
LVL 1

Author Comment

by:LostInWindows
ID: 39679831
[root@serv ~]# nmap -v -sT 192.168.0.55

Starting Nmap 6.01 ( http://nmap.org ) at 2013-11-26 21:21 MST
Initiating ARP Ping Scan at 21:21
Scanning 192.168.0.55 [1 port]
Completed ARP Ping Scan at 21:21, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 21:21
Completed Parallel DNS resolution of 1 host. at 21:21, 0.01s elapsed
Initiating Connect Scan at 21:21
Scanning 192.168.0.55 [1000 ports]
Discovered open port 3389/tcp on 192.168.0.55
Discovered open port 445/tcp on 192.168.0.55
Discovered open port 135/tcp on 192.168.0.55
Discovered open port 139/tcp on 192.168.0.55
Discovered open port 49160/tcp on 192.168.0.55
Completed Connect Scan at 21:21, 4.41s elapsed (1000 total ports)
Nmap scan report for 192.168.0.55
0
 
LVL 1

Author Closing Comment

by:LostInWindows
ID: 39680845
Thanks for the help. At least I have the IP tables correct. My RDP doesn't work but one step at a time. Thank you again.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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