Are you sure you have forwarding active?
echo "1" >/proc/sys/net/ipv4/ip_forw
Main Topics
Browse All TopicsSay, I'm trying to forward port 8080 to ip 192.168.10.209 with no luck.
This is my firwall. Please HELP.
# Generated by iptables-save v1.3.5 on Mon Aug 24 00:19:39 2009
*mangle
:PREROUTING ACCEPT [4786:1771206]
:INPUT ACCEPT [4674:1763828]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [6304:3027677]
:POSTROUTING ACCEPT [6304:3027677]
-A OUTPUT -p udp -m udp --sport 4569 -j DSCP --set-dscp 0x2e
-A OUTPUT -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x2e
-A OUTPUT -p udp -m udp --sport 5060 -j DSCP --set-dscp 0x2e
COMMIT
# Completed on Mon Aug 24 00:19:39 2009
# Generated by iptables-save v1.3.5 on Mon Aug 24 00:19:39 2009
*nat
:PREROUTING ACCEPT [28:3178]
:POSTROUTING ACCEPT [108:18980]
:OUTPUT ACCEPT [108:18980]
-A PREROUTING -p tcp -m tcp --dport 8080:8888 -m state --state NEW -j DNAT --to-destination 192.168.10.209:8080
COMMIT
# Completed on Mon Aug 24 00:19:39 2009
# Generated by iptables-save v1.3.5 on Mon Aug 24 00:19:39 2009
*filter
:INPUT ACCEPT [3:276]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [6304:3027677]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 8080:8082 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 25 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1021 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1022 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1023 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5060 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 10000:20000 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 4569 -m state --state NEW -j ACCEPT
COMMIT
# Completed on Mon Aug 24 00:19:39 2009
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Tx. Still no luck:
This is the log: and shows connection -please help!
193: Aug 24 10:01:20 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18160 DF PROTO=TCP SPT=4052 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
194: Aug 24 10:01:23 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18194 DF PROTO=TCP SPT=4052 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
196: Aug 24 10:01:29 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18241 DF PROTO=TCP SPT=4053 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
213: Aug 24 10:01:31 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18284 DF PROTO=TCP SPT=4054 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
217: Aug 24 10:01:34 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18312 DF PROTO=TCP SPT=4054 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
218: Aug 24 10:01:40 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18384 DF PROTO=TCP SPT=4054 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
219: Aug 24 10:01:52 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18760 DF PROTO=TCP SPT=4058 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
220: Aug 24 10:01:55 trixbox1 kernel: IN=ppp0 OUT=eth0 SRC=144.146.153.69 DST=192.168.10.209 LEN=48 TOS=0x00 PREC=0x00 TTL=124 ID=18864 DF PROTO=TCP SPT=4058 DPT=8080 WINDOW=65535 RES=0x00 SYN URGP=0
*nat
:PREROUTING ACCEPT [114:14045]
:POSTROUTING ACCEPT [263:17744]
:OUTPUT ACCEPT [213:15344]
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 8080:8888 -j DNAT --to-destination 192.168.10.209:8080
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.10.209:8080
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.10.209:8080
COMMIT
*mangle
:PREROUTING ACCEPT [527579:41491490]
:INPUT ACCEPT [527235:41464566]
:FORWARD ACCEPT [236:11328]
:OUTPUT ACCEPT [637726:52022343]
:POSTROUTING ACCEPT [637962:52033671]
-A OUTPUT -p udp -m udp --sport 4569 -j DSCP --set-dscp 0x2e
-A OUTPUT -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x2e
-A OUTPUT -p udp -m udp --sport 5060 -j DSCP --set-dscp 0x2e
COMMIT
# Completed on Mon Aug 24 12:18:49 2009
# Generated by iptables-save v1.3.5 on Mon Aug 24 12:18:49 2009
*nat
:PREROUTING ACCEPT [278:28278]
:POSTROUTING ACCEPT [656:44806]
:OUTPUT ACCEPT [559:40150]
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 8080:8888 -j DNAT --to-destination 192.168.10.209:8080
-A PREROUTING -i ppp0 -p tcp -m tcp --dport 23 -j DNAT --to-destination 192.168.10.209:23
COMMIT
# Completed on Mon Aug 24 12:18:49 2009
# Generated by iptables-save v1.3.5 on Mon Aug 24 12:18:49 2009
*filter
:INPUT ACCEPT [30:1440]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [637726:52022343]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -i ppp0 -p tcp -m tcp --dport 23 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 8080:8082 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 25 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1021 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1022 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1023 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5060 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 10000:20000 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 4569 -m state --state NEW -j ACCEPT
COMMIT
# Completed on Mon Aug 24 12:18:49 2009
edit /etc/sysctl.conf to look like:
net.ipv4.ip_forward = 1
Changes to sysctl.conf take effect upon booting. If you want changes to take effect without rebooting, use the following:
# sysctl -p
now when you try to check if traffic is flowing through one of your rules, issue:
for FILTER table:
iptables -L -vn
for NAT table:
iptables -L -vn -t nat
if you still have problems after editing the sysctl.conf and restart, then I would recommend to move this rule:
-A FORWARD -j RH-Firewall-1-INPUT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
to look like
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
This is before looking the output of the iptables -L command ;-)
Best,
Gabriel
Redimido: Tx 4 the detailed help. Still having problem.
Millenium: See paste below:
[root@localhost sysconfig]# iptables -L -nv
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
7356 339K RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 9395 packets, 10M bytes)
pkts bytes target prot opt in out source destination
Chain RH-Firewall-1-INPUT (2 references)
pkts bytes target prot opt in out source destination
7347 337K ACCEPT all -- eth0 * 0.0.0.0/0 0.0.0.0/0
2 100 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
5 1219 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:23 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:1022 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:1023 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0 141.2.39.6 tcp dpt:5060 state NEW
0 0 ACCEPT udp -- * * 0.0.0.0/0 141.2.39.6 udp dpts:10000:20000 state NEW
0 0 ACCEPT udp -- * * 0.0.0.0/0 141.2.39.6 state NEW udp dpt:4569
0 0 LOG all -- ppp0 * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4
0 0 LOG tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp flags:!0x17/0x02 LOG flags 0 level 4 prefix `ALERT,NewNotSyn from eth:'
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp flags:!0x17/0x02
0 0 LOG tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02 LOG flags 0 level 4 prefix `ALERT,NEW FROM eth DROP:'
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02
0 0 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 LOG flags 0 level 4 prefix `ALERT PING DROP:'
0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8
2 186 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4 prefix `ALERT, REST INPUT DROP:'
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
[root@localhost sysconfig]#
__________________________
[root@localhost sysconfig]# iptables -L -vn -t nat
Chain PREROUTING (policy ACCEPT 11 packets, 1264 bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 tcp to:192.168.10.108:23
Chain POSTROUTING (policy ACCEPT 34 packets, 2082 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 34 packets, 2082 bytes)
pkts bytes target prot opt in out source destination
[root@localhost sysconfig]#
Attached goes a script that probably will fix your problems.
Place it at /etc/init.d/firewall and do a "chmod 700 /etc/init.d/firewall" then execute it.
Notice that Red Hat/CentOS use a single chain for both FORWARD and INPUT chains, so i can't really tell what is trafic is directed to the box and what is supposed to go thru (If that is your firewall, INPUT is probably just port 22).
Also i removed all the logging, that can be added later. To debug the access, use tcpdump instead (run it like this "tcpdump -i any host 144.146.153.69 -vn") and you should be able to see the NAT and the Foward.
Please let me know the result.
Tx, but get
[root@localhost init.d]# chmod 700 firewall
[root@localhost init.d]# ./firewall
iptables v1.3.5: invalid TCP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.5: invalid UDP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.5: invalid UDP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
[root@localhost init.d]# service firewall stop
iptables v1.3.5: invalid TCP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.5: invalid UDP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.5: invalid UDP port/service `--dport' specified
Try `iptables -h' or 'iptables --help' for more information.
[root@localhost init.d]#
If you know the source ip, use it, you going to be able to see every packet. If you don't know, run it like this: "tcpdump -i any port 8080 -vn"
Please paste the output here so i can see what's going on but it's kinda hard to think that it doesn't work, such a simple script.
Would help as well if you told me how is your network set up, can you give us the following info:
On the firewall:
"ifconfig -a"
"route -n"
On the machine that you directing the port 8080 (with the ip 192.168.10.209):
If its a windows:
"ipconfig /all"
"route print"
If its a linux:
"ifconfig -a"
"route -n"
Tx. Please see attached.
Also a telnet attempt from a public pc:
[root@localhost init.d]# tcpdump -i any port 23 -vn
tcpdump: WARNING: Promiscuous mode not supported on the "any" device
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 96 bytes
20:59:11.582094 IP (tos 0x0, ttl 54, id 33392, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 196.146.152.179.telnet: S, cksum 0x3b1c (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579708988 0,nop,wscale 7>
20:59:11.583753 IP (tos 0x0, ttl 53, id 33392, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 192.168.10.108.telnet: S, cksum 0xae4d (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579708988 0,nop,wscale 7>
20:59:14.577767 IP (tos 0x0, ttl 54, id 33393, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 196.146.152.179.telnet: S, cksum 0x2f64 (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579711988 0,nop,wscale 7>
20:59:14.577804 IP (tos 0x0, ttl 53, id 33393, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 192.168.10.108.telnet: S, cksum 0xa295 (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579711988 0,nop,wscale 7>
20:59:20.578571 IP (tos 0x0, ttl 54, id 33394, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 196.146.152.179.telnet: S, cksum 0x17f4 (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579717988 0,nop,wscale 7>
20:59:20.578614 IP (tos 0x0, ttl 53, id 33394, offset 0, flags [DF], proto: TCP (6), length: 60) 141.222.39.3.34130 > 192.168.10.108.telnet: S, cksum 0x8b25 (correct), 2177664076:2177664076(0) win 5840 <mss 1412,sackOK,timestamp 3579717988 0,nop,wscale 7>
6 packets captured
6 packets received by filter
0 packets dropped by kernel
[root@localhost init.d]#
The attached code means that the NAT/Forward rules (which is what you call port forward) is working, the packed entered in the ppp0, was redirected to the internal ip 192.168.10.108. The ttl changes means he crossed the box (forward rule) and the you can see that he translated the destination ip.
What is happening is that the internal computer is either filtering the packets or its route to the ip 141.222.39.3 is not configured (he either has a specific route that host/network configured wrongly or has no default route configured at all).
To fix that i really need the routing table in both machines and ip configuration for the machine with the ip 192.168.10.108, if it's too big to paste, please copy/paste in a txt file and attach it here.
Also, please don't use any built-in firewall commands as "iptables-save", they aren't needed anymore. Just run once the file /etc/init.d/firewall, then run "chkconfig firewall on" and "chkconfig iptables off", that will enable the firewall rules i created for you at boot.
If you need to change/create/delete any rule, simple edit the file ("vi /etc/init.d/firewall") and run again the script.
Last but not least, try to do a telnet from the box to the internal machine and see if it connects (telnet 192.168.10.108), that will help us debug.
Just to help explaining, so you understand Better:
> [root@localhost rc.d]# telnet 196.146.152.179
> Trying 196.146.152.179...
> telnet: connect to address 196.146.152.179: Connection refused
> telnet: Unable to connect to remote host: Connection refused
You are trying to connect not to the internal machine with this, but to the own box and your NAT is only for the packets that comes from the interface ppp0 (internet packets) not lo (loopback) so it won't redirect it and since the own box has no telnet server running, you gonna get a connection refuse (the box isn't listenning on the port tcp 23).
Since you a have ppp device in there i assume that is the routing table for the firewall. I really gotta ask this, why do you have so many specific routes for internet address instead of a simple default route (everything points to ppp0 regardless) ?
Anyway, you have no route for the network/ip 141.222.39.3 and that is one of the causes but i still suspect that the internal machine (192.168.10.108) has issues related to ip configuration/routing.
Can you attach the routing table and the ip configuration for that machine also ?
Btw, this is a sign that the service is running and is reachable from the firewall:
> root@localhost init.d]# telnet 192.168.10.108
> Trying 192.168.10.108...
> Connected to 192.168.10.108 (192.168.10.108).
> Escape character is '^]'.
So it's PROBABLY just routing issues.
In South Africa local bandwidth is charged at about a quarter the price of international bandwdith. ppp0 is a local only connection and etho is attached to the international gateway and hence the routes.
There is only one linux machine and the firewall is running on it. The ifconfig and route tables I've attached are for it.
I think you are correct in your assesment.
> In South Africa local bandwidth is charged at about a quarter the price of international bandwdith. ppp0 is a local only connection and etho is attached to the international gateway and hence the routes.
Alright, then for that linux you need to add a route for the network 141.222.0.0/16 (or one route specific for the ip 141.222.39.3).
> There is only one linux machine and the firewall is running on it. The ifconfig and route tables I've attached are for it.
Yes but i still need to check the routing table and ip configuration for the machine 192.168.10.108, my guess is that there is the problem.
If its a windows you can get that data using "ipconfig -a" and "route print".
What i can do for you is, since you are able to access it from the linux, i can do another NAT to when the packet gets to the internal device (the Quintum) it comes with the firewall internal ip instead of the original source ip, so it would know where to answer.
That is kinda bad for application logs cause every access is going to show as if it was originated from the firewall but its going to work, anyway attached is the script with the update.
Added the following line:
$IPTABLES -t nat -A POSTROUTING -o eth0 -d 192.168.10.0/24 -j SNAT --to-source 192.168.10.77
Business Accounts
Answer for Membership
by: DetailsITPosted on 2009-08-23 at 15:53:39ID: 25164617
Here are two examples:
-A PREROUTING -p tcp -i eth0 -d xxx.xxx.xxx.xxx --dport 8080 -j DNAT --to 192.168.10.209:8080
-A FORWARD -p tcp -i eth0 -d 192.168.10.209 --dport 8080 -j ACCEPT
-A PREROUTING -i eth0 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.10.209:8080
-A INPUT -i eth0 -p tcp -m tcp --dport 8080 -j ACCEPT