Problems with Portforwarding
Hi there, i'm new on this list and i'm from germany, so excuse my english. Well i have a problem, i have a router/gateway with Redhat 9 running on it and i have 2 W2k Computers behind it. Now i want to forward some ports to the Windows-Clients, i have tried some configurations but i still get the "connection refused" error. Here the part of my script whitch belongs to the port-forwarding.
---
$IPTABLES -t nat -A PREROUTING -j DNAT -p tcp -s 0/0 --dport 4711 -i ppp0 --to-destination 192.168.0.2:4711 $IPTABLES -A FORWARD --dport 4711 -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -p tcp -s 0/0 -d 192.168.0.2
$IPTABLES -t nat -A PREROUTING -j DNAT -p tcp -s 0/0 --dport 4712 -i ppp0 --to-destination 192.168.0.3:8080 $IPTABLES -A FORWARD --dport 8080 -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -p tcp -s 0/0 -d 192.168.0.3
---
don't know where the Problem is, so i hope you can help me,
thnx.
Quoted 5 lines · Ronny Fauth
Well i have a problem, i have a router/gateway with Redhat 9 running on it and i have 2 W2k Computers behind it. Now i want to forward some ports to the Windows-Clients, i have tried some configurations but i still get the "connection refused" error. Here the part of my script which belongs to the port-forwarding.
1. How are you testing these rules?
2. What does "iptables -L -nvx; iptables -L -t nat -nvx" show for these rules
- do the packet/byte counters show that any packets are being processed?
Regards,
Antony.
Signature · 9 lines
Programming is a Dark Art, and it will always be. The programmer is
fighting against the two most destructive forces in the universe:
entropy and human stupidity. They're not things you can always
overcome with a "methodology" or on a schedule.
- Damian Conway, Perl God
Please reply to the list;
please don't CC me.Quoted 4 lines · Antony Stone
1. How are you testing these rules?
Well, i'm trying to connect via the Inet to one of these Ports.... how else can i test something like that?
Quoted 3 lines
2. What does "iptables -L -nvx; iptables -L -t nat -nvx" show for these rules - do the packet/byte counters show that any packets are being processed?
yes, the counter gets higher after every refused connection
here's a bigger part of the Firewallscript and the the "iptables -L -nvx; iptables -L -t nat -nvx"
#
# Rule 0(NAT)
#
#
$IPTABLES -t nat -A POSTROUTING -o ppp0 -s 192.168.0.0/16 -j MASQUERADE #
#
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#
# Rule 0(global)
#
# SSH Zugang zur Firewall
#
$IPTABLES -A INPUT -p tcp -d $interface_ppp0 --destination-port 22 -m state --state NEW -j ACCEPT $IPTABLES -A INPUT -p tcp -d 160.0.0.1 --destination-port 22 -m state --state NEW -j ACCEPT $IPTABLES -A INPUT -p tcp -d 192.168.0.1 --destination-port 22 -m state --state NEW -j ACCEPT
#
# TEST Zugang zum BOT
#
$IPTABLES -A INPUT -p tcp -d $interface_ppp0 --destination-port 4662 -m state --state NEW -j ACCEPT $IPTABLES -A INPUT -p tcp -d 160.0.0.1 --destination-port 4662 -m state --state NEW -j ACCEPT $IPTABLES -A INPUT -p tcp -d 192.168.0.1 --destination-port 4662 -m state --state NEW -j ACCEPT
#
# Rule 1(global)
#
# 'masquerading' Regel
#
$IPTABLES -A INPUT -s 192.168.0.0/16 -m state --state NEW -j ACCEPT
$IPTABLES -A OUTPUT -s 192.168.0.0/16 -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.0/16 -m state --state NEW -j ACCEPT
#
# Rule 2(global)
#
# 'catch all' Regel
#
$IPTABLES -N RULE_2
$IPTABLES -A OUTPUT -m state --state NEW -j RULE_2
$IPTABLES -A INPUT -m state --state NEW -j RULE_2
$IPTABLES -A FORWARD -m state --state NEW -j RULE_2
#$IPTABLES -A RULE_2 -j LOG --log-level info --log-prefix "RULE 2 -- ACCEPT " $IPTABLES -A RULE_2 -j ACCEPT
#
$IPTABLES -t nat -A PREROUTING -j DNAT -p tcp -s 0/0 --dport 4662 -i ppp0 --to-destination 192.168.0.2 $IPTABLES -A FORWARD -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -p tcp -s 0/0 -d 192.168.0.2
$IPTABLES -t nat -A PREROUTING -j DNAT -p tcp -s 0/0 --dport 4711 -i ppp0 --to-destination 192.168.0.2 $IPTABLES -A FORWARD -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -p tcp -s 0/0 -d 192.168.0.2
$IPTABLES -t nat -A PREROUTING -j DNAT -p tcp -s 0/0 --dport 4712 -i ppp0 --to-destination 192.168.0.3 $IPTABLES -A FORWARD -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -p tcp -s 0/0 -d 192.168.0.3
#
echo 1 > /proc/sys/net/ipv4/ip_forward
-----------------------------------------------------------------------------------------------------------------------------
[test@Warhawk /]# iptables -L -nvx
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out
source destination
170 9620 ACCEPT all -- * * 0.0.0.0/0
0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT tcp -- * * 0.0.0.0/0
80.135.234.34 tcp dpt:22 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
160.0.0.1 tcp dpt:22 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
192.168.0.1 tcp dpt:22 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
80.135.234.34 tcp dpt:4662 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
160.0.0.1 tcp dpt:4662 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
192.168.0.1 tcp dpt:4662 state NEW
0 0 ACCEPT all -- * * 192.168.0.0/16
0.0.0.0/0 state NEW
0 0 RULE_2 all -- * * 0.0.0.0/0 0.0.0.0/0 state NEW
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out
source destination
239 87991 ACCEPT all -- * * 0.0.0.0/0
0.0.0.0/0 state RELATED,ESTABLISHED
9 432 ACCEPT all -- * * 192.168.0.0/16
0.0.0.0/0 state NEW
2 96 RULE_2 all -- * * 0.0.0.0/0
0.0.0.0/0 state NEW
0 0 ACCEPT tcp -- * * 0.0.0.0/0
192.168.0.2 state NEW,RELATED,ESTABLISHED
0 0 ACCEPT tcp -- * * 0.0.0.0/0 192.168.0.2 state NEW,RELATED,ESTABLISHED
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out
source destination
147 14316 ACCEPT all -- * * 0.0.0.0/0
0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT all -- * * 192.168.0.0/16
0.0.0.0/0 state NEW
0 0 RULE_2 all -- * * 0.0.0.0/0 0.0.0.0/0 state NEW
Chain RULE_2 (3 references)
pkts bytes target prot opt in out
source destination
2 96 ACCEPT all -- * * 0.0.0.0/0
0.0.0.0/0
--------------------------------------------------------------------------------------
[test@Warhawk /]# iptables -L -t nat -nvx
Chain PREROUTING (policy ACCEPT 54819 packets, 3278426 bytes)
pkts bytes target prot opt in out
source destination
5 264 DNAT tcp -- ppp0 * 0.0.0.0/0
0.0.0.0/0 tcp dpt:4662 to:192.168.0.2
0 0 DNAT tcp -- ppp0 * 0.0.0.0/0
0.0.0.0/0 tcp dpt:4711 to:192.168.0.2
0 0 DNAT tcp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4712 to:192.168.0.3
Chain POSTROUTING (policy ACCEPT 5561 packets, 306745 bytes)
pkts bytes target prot opt in out
source destination
63 3024 MASQUERADE all -- * ppp0
192.168.0.0/16 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 2162 packets, 135099 bytes)
pkts bytes target prot opt in out
source destination
Sorry Antony, don't know why my mailclient sent the first mail only to you
Re: Problems with Portforwarding -- Loopback problems---
I've found out what the Problem is, well i tried to connect to my other Computer at my homenetwork via Inet, well it looks like this
Test --> Router/Gateway ---> Inet --> Router/Gateway --> Test2
and this isn't acceptet by my Gateway... connections from outside my network are redirected properly. Well, how cann i tell my Router/Gateway that it should accept Loopback's ?
Re: Problems with Portforwarding -- Loopback problems---
Quoted 8 lines · Ronny Fauth
I've found out what the Problem is, well i tried to connect to my other Computer at my homenetwork via Inet, well it looks like this
Test --> Router/Gateway ---> Inet --> Router/Gateway --> Test2
and this isn't acceptet by my Gateway... connections from outside my network are redirected properly. Well, how cann i tell my Router/Gateway that it should accept Loopback's ?
What do you mean by "loopbacks"?
Give us some IP addresses on the above diagram, and explain exactly what you are trying to do (eg: client on IP address xxx connects to server on IP address yyy on TCP port zzz etc), and we might understand...
Regards,
Antony.
Signature · 7 lines
It is also possible that putting the birds in a laboratory setting
inadvertently renders them relatively incompetent.
- Daniel C Dennet
Please reply to the list;
please don't CC me.Re: Problems with Portforwarding -- Loopback problems---
In reply to a message not in the archiveQuoted 11 lines · Ronny Fauth
Quoted 1 line · Antony Stone
Quoted 1 line
Test --> Router/Gateway ---> Inet --> Router/Gateway --> Test2
192.168.0.2 ---> 192.168.0.1 ---> dynamicIP, the IP i'm using atthe Internet ---> 192.168.0.1 ---> 192.168.0.3
i want to forward some ports, port 192.168.0.1:4711 should be forwarded to 192.168.0.2:4711, well this works, but i want to try it..... so i'm typing on a browser on 192.168.0.3 "http://xxx.dyndns.org:4711/" and this doesn't work, if i'm typing "http://192.168.0.2:4711" it works, this is the major problem i have.
Think about the replies.
192.168.0.3 sends a packet to xxx.dyndns.org, that gets translated by 192.168.0.1 into 192.168.0.2
192.168.0.2 receives the packet, sees that the sender is 192.168.0.3, and replies.
Therefore 192.168.0.3 sent a packet to xxx.dyndns.org and got a reply from
192.168.0.2. It can't handle this, so fails.
(I'm assuming in all the above that xxx.dyndns.org does not resolve to 192.168.0.2, of course).
Also see http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO-10.html
Regards,
Antony.
Signature · 2 lines
If the human brain were so simple that we could understand it, we'd be so simple that we couldn't.
Re: Problems with Portforwarding -- Loopback problems---
In reply to a message not in the archiveQuoted 7 lines · Ronny Fauth
Quoted 5 lines · Antony Stone
Think about the replies.
192.168.0.3 sends a packet to xxx.dyndns.org, that gets translated by 192.168.0.1 into 192.168.0.2
Quoted 8 lines
Quoted 5 lines
192.168.0.2 receives the packet, sees that the sender is 192.168.0.3, and replies.
Therefore 192.168.0.3 sent a packet to xxx.dyndns.org and got a reply from
192.168.0.2. It can't handle this, so fails.Well ya, sounds logically..... but how can i solve this Problem? so i can test wether the forwarding is working or not
This depends on whether you need the address translation system to work (after you've tested it and decided it's okay):
a) only from the Internet, or
b) from both the Internet and the local network.
If (a), then you should test it from the Internet, because that's what you need to work correctly - testing from the local network is not the same.
If (b), then you should be using split DNS to give the private address to local clients, and the public address to external clients - then each will connect to the correct IP address depending on where they're starting from.
Of course the other solution is to put local clients, and the server you're talking to, on separate subnets from the firewall, so no matter who talks to them, the packets always go through the firewall and always get NATted.
Regards,
Antony.
Signature · 4 lines
People who use Microsoft software should be certified.
Please reply to the list;
please don't CC me.