Skip to contentSkip to conversation

Forwarding help

DISCUSSION [email protected] 4 participants 9 messages Nov 26, 2003 – Nov 27, 2003

lore
Share & tools
lore
#0 lore raw

hello
i use iptables .7, but it does not work (forward) , any ideas? thank you ,
ps: same rules down i have make for tcp match not only for udp

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F FORWARD
iptables -t nat -F
iptables -A FORWARD -j LOG
iptables -A FORWARD -p udp -d ip --dport port -j ACCEPT iptables -t nat -A PREROUTING -p udp -d ip --dport port -j DNAT --to ip:port

#1 lore raw

On Wed, 26 Nov 2003 [email protected] wrote:

||hello
||i use iptables .7, but it does not work (forward) , any ideas?
||thank you ,
||ps: same rules down i have make for tcp match not only for udp
||
||echo "1" > /proc/sys/net/ipv4/ip_forward
||iptables -F FORWARD
||iptables -t nat -F
||iptables -A FORWARD -j LOG
||iptables -A FORWARD -p udp -d ip --dport port -j ACCEPT
||iptables -t nat -A PREROUTING -p udp -d ip --dport port -j DNAT --to
||ip:port

iptables -t nat -A PREROUTING -p udp -d ip --dport port -j DNAT --to-destination ip

||
||

+ Lucas de Camargo Zechim
+ Administrador TI
+
+ phone: 55 19 3492 8894
+
+ CNEC Capivari

+   Rua Barão do Rio Branco, 374
+   13360-000
+   Capivari / São Paulo / Brasil

+
+ email by pine 4.58 / Slackware Linux 9.1 / kernel 2.4.22-xfs
+ "Os poderosos podem matar uma, duas ou três rosas, mas
+ jamais consiguirão deter a primavera inteira"

#2 lore raw
In reply to [email protected]
Quoted 5 lines · On Wednesday 26 November 2003 10:03 pm, [email protected] wrote:

hello
i use iptables .7, but it does not work (forward) , any ideas? thank you ,
ps: same rules down i have make for tcp match not only for udp

Quoted 7 lines

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F FORWARD
iptables -t nat -F
iptables -A FORWARD -j LOG
iptables -A FORWARD -p udp -d ip --dport port -j ACCEPT iptables -t nat -A PREROUTING -p udp -d ip --dport port -j DNAT --to ip:port

I assume in that last rule the two occurrences of "ip" are different.

Which one is specified in the FORWARD rule? Make sure it is the translated
address (ie the address on the packet after it has gone through the PREROUTING rule), because it will no longer have the original destination address by the time it hits the FORWARD chain.

If that's not the answer then post your actual ruleset (by all means munge the addresses if you don't want us to know exactly what they are, but let us see which ones are which...)

Antony.

Signature · 4 lines
Wanted: telepath.   You know where to apply.

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw

Thx for answer antony
here the complet rules list, sorry for this xx.xx.xx it was stupid from me (full range)...
Ip : xx.xxx.24.51 , should be fw to ip: xx.xxx.24.58
(only for 1 port)
thank you

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F FORWARD
iptables -t nat -F
iptables -A FORWARD -j LOG
iptables -A FORWARD -p udp -d xx.xxx.24.58 --dport xxx21 -j ACCEPT iptables -t nat -A PREROUTING -p udp -d xx.xxx.24.51 --dport xxx21 -j DNAT --to xx.xxx.24.58:xx021

iptables -A FORWARD -p tcp -d xx.xxx.24.58 --dport xxx21 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -d xx.xxx.24.51 --dport xxx21 -j DNAT --to xx.xxx.xx.58:xxx21

Quoted 15 lines · On Wednesday 26 November 2003 10:03 pm, [email protected] wrote:
Quoted 6 lines

hello
i use iptables .7, but it does not work (forward) , any ideas? thank you ,
ps: same rules down i have make for tcp match not only for udp

Quoted 7 lines

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F FORWARD
iptables -t nat -F
iptables -A FORWARD -j LOG
iptables -A FORWARD -p udp -d ip --dport port -j ACCEPT iptables -t nat -A PREROUTING -p udp -d ip --dport port -j DNAT --to ip:port

Quoted 3 lines

I assume in that last rule the two occurrences of "ip" are different.

Which one is specified in the FORWARD rule? Make sure it is the

translated

Quoted 5 lines

address (ie the address on the packet after it has gone through the PREROUTING rule), because it will no longer have the original destination address by the time it hits the FORWARD chain.

If that's not the answer then post your actual ruleset (by all means munge

the

Quoted 1 line

addresses if you don't want us to know exactly what they are, but let us

see

Quoted 8 lines

which ones are which...)

Antony.

Signature · 3 lines
Wanted: telepath.   You know where to apply.

                                                     Please reply to the

list;

Quoted 1 line

please don't CC

me.

Quoted 3 lines
#4 lore raw
Quoted 15 lines · On Thursday 27 November 2003 11:07 am, [email protected] wrote:

Thx for answer antony
here the complet rules list, sorry for this xx.xx.xx it was stupid from me (full range)...
Ip : xx.xxx.24.51 , should be fw to ip: xx.xxx.24.58
(only for 1 port)
thank you

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F FORWARD
iptables -t nat -F
iptables -A FORWARD -j LOG
iptables -A FORWARD -p udp -d xx.xxx.24.58 --dport xxx21 -j ACCEPT iptables -t nat -A PREROUTING -p udp -d xx.xxx.24.51 --dport xxx21 -j DNAT --to xx.xxx.24.58:xx021

Quoted 3 lines

iptables -A FORWARD -p tcp -d xx.xxx.24.58 --dport xxx21 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -d xx.xxx.24.51 --dport xxx21 -j DNAT --to xx.xxx.xx.58:xxx21

The only thing I can see missing here is a rule to allow the replies back through the Firewall in the other direction (the FORWARD rules you have shown only allow the first packet of the initial connection).

So "iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT" might be a good idea.

However, the fact that the original address, and the translated address, are both in the same network range, makes me ask "is the client which is trying to access xx.xxx.25.51 on the other side of the Firewall (ie the client must not be on the same subnet as the server xx.xxx.25.58)?"

My final question is: what is the actual port number (or alternatively, what
is the service you are trying to NAT)? Are you sure it is a protocol which
doesn't mind being NATted (some do, some don't, some need helpers)?

Antony.

Signature · 5 lines
Abandon hope, all ye who enter here.
You'll feel much better about things once you do.

                                                     Please reply to the list;
                                                           please don't CC me.
#5 lore raw

so
a.)

Quoted 1 line

So "iptables -I FORWARD -m state --state >ESTABLISHED,RELATED -j ACCEPT"

might

Quoted 1 line

be a good idea.

i should include this ?

b.) the port / service is a udp/tcp , port of a half - life game server, so the clients are not on the same subnet
they are connecting to x.24.51 > and should FW to .24.58:

cya

#6 lore raw
Quoted 4 lines · On Thursday 27 November 2003 12:48 pm, [email protected] wrote:
Quoted 2 lines

So "iptables -I FORWARD -m state --state >ESTABLISHED,RELATED -j ACCEPT" might be a good idea.

i should include this ?

This will alloow the reply packets pack again - if you don't have this, you need a specific rule to allow those the same as you have a specific rule to
allow the original packets. Don't forget communications go both ways
through a firewall :)

Quoted 3 lines

b.) the port / service is a udp/tcp , port of a half - life game server, so the clients are not on the same subnet
they are connecting to x.24.51 > and should FW to .24.58:

Does halflife work through NAT?

I don't know (maybe someone else here does), but you should be aware that there are some protocols which just work through NAT, some which are a bit of a challenge, and some which won't work at all.

I don't know which group halflife falls into.

Antony.

Signature · 4 lines
Most people have more than the average number of legs.

                                                     Please reply to the list;
                                                           please don't CC me.
#7 lore raw
Quoted 16 lines · Antony Stone
Quoted 4 lines · On Thursday 27 November 2003 12:48 pm, [email protected] wrote:
Quoted 2 lines

So "iptables -I FORWARD -m state --state >ESTABLISHED,RELATED -j ACCEPT" might be a good idea.

i should include this ?

This will alloow the reply packets pack again - if you don't have this, you need a specific rule to allow those the same as you have a specific rule to
allow the original packets. Don't forget communications go both ways
through a firewall :)

Quoted 3 lines

b.) the port / service is a udp/tcp , port of a half - life game server, so the clients are not on the same subnet
they are connecting to x.24.51 > and should FW to .24.58:

Quoted 6 lines

Does halflife work through NAT?

I don't know (maybe someone else here does), but you should be aware that there are some protocols which just work through NAT, some which are a bit of a challenge, and some which won't work at all.

Halflife like most network games uses UDP, so should be able to work through nat.

Quoted 3 lines

I don't know which group halflife falls into.

Antony.

Signature · 7 lines
--
Raymond Leach <[email protected]>
Network Support Specialist
http://www.knowledgefactory.co.za
"lynx -source http://www.rchq.co.za/raymondl.asc | gpg --import"
Key fingerprint = 7209 A695 9EE0 E971 A9AD  00EE 8757 EE47 F06F FB28
--
#8 lore raw
Quoted 2 lines · Ray Leach

Halflife like most network games uses UDP, so should be able to work through nat.

I'm not sure I see the reasoning here. Just because something uses UDP
doesn't automatically mean it will work through nat?

The criterion for whether a protocol will work through nat or not is whether the IP address that each end-system thinks it has gets embedded in the
communication somewhere or not. If those addresses do get embedded in the
packet contents, then it won't work through nat without a helper which understands where and how the embedding is done, and can fiddle about with it.

I don't think it makes any difference whether the packets get to the other end by TCP, UDP or anything else?

Antony.

Signature · 6 lines
The first fifty percent of an engineering project takes ninety percent of the 
time, and the remaining fifty percent takes another ninety percent of the 
time.

                                                     Please reply to the list;
                                                           please don't CC me.