How to portforward with iptables?


 
Thread Tools Search this Thread
Special Forums IP Networking How to portforward with iptables?
# 1  
Old 02-20-2013
RedHat How to portforward with iptables?

I currently installed openvpn on CentOS 6 64bit and everything is working fine but I want to portforward a client "user" so they can use that port here is what i thought it might work

Code:
iptables -t nat -A PREROUTING -p udp -d SERVERIP --dport 3074 -j DNAT --to-destination 10.8.0.6:3074

# 2  
Old 02-20-2013
# 3  
Old 02-20-2013
Code:
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.2:8080

But eht0 is not even on my network.
# 4  
Old 02-21-2013
Well, you need to use the right symbols for your machine, and you need a FORWARD ACCEPT rule for the return trip. Port Forwarding Using iptables - Linux Tutorials - Fclose.com
# 5  
Old 02-21-2013
This is my current iptables

Code:
# Generated by iptables-save v1.4.7 on Wed Feb 20 21:17:31 2013
*mangle
:PREROUTING ACCEPT [37157:2159381]
:INPUT ACCEPT [37133:2156855]
:FORWARD ACCEPT [24:2526]
:OUTPUT ACCEPT [60460:8243106]
:POSTROUTING ACCEPT [60484:8245632]
COMMIT
# Completed on Wed Feb 20 21:17:31 2013
# Generated by iptables-save v1.4.7 on Wed Feb 20 21:17:31 2013
*filter
:INPUT ACCEPT [37133:2156855]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [60460:8243106]
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A FORWARD -s 10.8.0.0/24 -j ACCEPT 
COMMIT
# Completed on Wed Feb 20 21:17:31 2013
# Generated by iptables-save v1.4.7 on Wed Feb 20 21:17:31 2013
*nat
:PREROUTING ACCEPT [5:210]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -p tcp -m tcp --dport 33891 -j DNAT --to-destination 10.8.0.6:3389 
-A PREROUTING -d 37.0.122.190 -p udp -m udp --dport 3074 -j DNAT --to-destination 10.8.0.6:3074
-A PREROUTING -d 37.0.122.190 -p tcp -m tcp --dport 3074 -j DNAT --to-destination 10.8.0.6:3074 
-A PREROUTING -d 37.0.122.190 -p udp -m udp --dport 1604 -j DNAT --to-destination 10.8.0.10:1604
-A PREROUTING -d 37.0.122.190 -p tcp -m tcp --dport 1604 -j DNAT --to-destination 10.8.0.10:1604
-A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source 37.0.122.190 
COMMIT
# Completed on Wed Feb 20 21:17:31 2013

# 6  
Old 02-21-2013
The example there suggests you need these:
Code:
iptables -A FORWARD -p tcp -d 10.8.0.6 --dport 3074 -j ACCEPT
iptables -A FORWARD -p udp -d 10.8.0.6 --dport 3074 -j ACCEPT

# 7  
Old 02-21-2013
I tried that too,
and then did
service iptables save
service iptables restart
and still not available.

I am currently using canyouseeme and ping. eu /port-chk/
to check if the ports are opening up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

iptables

Hi I need help with an iptables configuration, this is what I have server A Server B A and B are using different gateways i am sending port 22 from A to B, I see the packages coming in B but B is not sending the package to internet. please give me some examples. (0 Replies)
Discussion started by: lmartinez073
0 Replies

2. IP Networking

Help with iptables

photo... (1 Reply)
Discussion started by: beerpong1
1 Replies

3. UNIX for Dummies Questions & Answers

Help with iptables

Hi, I just build a Linux server, I said yes to enable the firewall. I only choose SSH conneciton. When I check the iptables. I see all of this (see below). I want to reject every thing only allow SSH from subnet 192.168.1.xx. Can you advise, how to do. Chain RH-Firewall-1-INPUT (2... (2 Replies)
Discussion started by: samnyc
2 Replies

4. UNIX for Dummies Questions & Answers

help with iptables

Hi, On the IPTABLES, I did iptables --flush. I want to start fresh. Now I only want two things. Allow one ip address to this server. Allow port 443 as incoming from every where. Please advice how to do this. This is what I did so for. iptables -I INPUT -i eth0 -s 1.2.3.4 -j ACCEPT... (5 Replies)
Discussion started by: samnyc
5 Replies

5. IP Networking

squid and iptables

Hello all I have a little network as described below. A Linux router/proxy with the External interface: 192.168.121.240 Internal interface: 10.0.0.2 and a DMZ interface: 10.1.0.2 On the DMZ i have a linux with ip: 10.1.0.10 and apache2, php5, mysql and samba installed. On the internal... (0 Replies)
Discussion started by: davano
0 Replies

6. IP Networking

iptables changes

Hello We have one linux machine in the office which happens to be an important firewall. I just know the basics and need to make one change Essentially it is forward mysql traffic to another internal machine. This is the original rule (forward to 192.20.0.17) which is working ... (0 Replies)
Discussion started by: rina5392
0 Replies

7. IP Networking

Iptables

What should be the iptables rule so that only the subnet 64.61.11.224/255.255.255.248 may access the mysql port 3306 (1 Reply)
Discussion started by: proactiveaditya
1 Replies

8. IP Networking

Iptables

Thanks in advance I have to remove ip_tables_name from /proc/net/... i was trying to do so and getting the following error cmd : rm ip_tables_names error : rm: remove regular empty file `ip_tables_names'? y rm: cannot remove `ip_tables_names': Operation not permitted (4 Replies)
Discussion started by: sudeepiit
4 Replies

9. IP Networking

Need help with iptables

Trying to create a whitelist to limit bandwidth. My sync speed is 1536/256 kbps. Simple rules in order: 1. Do not limit (or set to 1536/256) MAC 00:00:00:00:00 (computer is in 192.168.1.0/24). 2. Do not limit (or set to 1536/256) MAC 00:00:00:00:01 (computer is in 192.168.1.0/24). 3. Do not... (1 Reply)
Discussion started by: kripz
1 Replies

10. IP Networking

IPtables

Hey guys, I have just started using IP tables and was wondering if anyone could direct me to any good online resources as I am totally new to this. Thanks. (1 Reply)
Discussion started by: 182x
1 Replies
Login or Register to Ask a Question