Skip to contentSkip to conversation

Iptables SNAT for pkt generated by internal process

DISCUSSION [email protected] 3 participants 3 messages May 16, 2006

lore
Share & tools
lore
#0 lore raw

I would like to use iptables to translate the source of IP datagrams generated inside a router for some particular applications (such as
syslog: protocol UDP, destination port 514). I thought to use an iptables rule defined by an OUTPUT chain (which let manipulate datagram generated from local process) and by the target SNAT (which let to translate ip source) -> iptables -t nat -A OUTPUT -p udp --dport 514 -j SNAT --to x.x.x.x. The problem is that the OUTPUT chain cannot be used with the target SNAT!
Has anybody any idea about which is the best and simplest way to get the result described above?

Thanks for Your collaboration.
Monia Cheli

Tiscali ADSL 4 Mega Flat

Naviga senza limiti a 19,95 Euro al mese con 4 Megabps di velocita'. Attiva subito: hai 2 MESI di canone adsl GRATIS!

In piu', se sei raggiunto dalla rete Tiscali, telefoni senza pagare il canone Telecom.

Scopri subito come risparmiare!

http://abbonati.tiscali.it/prodotti/adsl/tc/4flat/

#1 lore raw
Quoted 12 lines · [email protected] wrote:

I would like to use iptables to translate the source of IP datagrams generated inside a router for some particular applications (such as syslog: protocol UDP, destination port 514). I thought to use an iptables rule defined by an OUTPUT chain (which let manipulate datagram generated from local process) and by the target SNAT (which let to translate ip source) -> iptables -t nat -A OUTPUT -p udp --dport 514 -j SNAT --to x.x.x.x. The problem is that the OUTPUT chain cannot be used with the target SNAT! Has anybody any idea about which is the best and simplest way to get the result described above?

Thanks for Your collaboration.
Monia Cheli

Tiscali ADSL 4 Mega Flat

Quoted 11 lines

Naviga senza limiti a 19,95 Euro al mese con 4 Megabps di velocita'. Attiva subito: hai 2 MESI di canone adsl GRATIS!

In piu', se sei raggiunto dalla rete Tiscali, telefoni senza pagare il canone Telecom.

Scopri subito come risparmiare!

http://abbonati.tiscali.it/prodotti/adsl/tc/4flat/

You do SNAT in POSTROUTING. Local generated packets also enter POSTROUTING. You may want to match source ip or .. you can mark packets in mangle OUTPUT, and then SNAT in POSTROUTING matching only the mark value with mark match.

#2 lore raw
In reply to [email protected]
Quoted 12 lines · [email protected] wrote:

I would like to use iptables to translate the source of IP datagrams generated inside a router for some particular applications (such as syslog: protocol UDP, destination port 514). I thought to use an iptables rule defined by an OUTPUT chain (which let manipulate datagram generated from local process) and by the target SNAT (which let to translate ip source) -> iptables -t nat -A OUTPUT -p udp --dport 514 -j SNAT --to x.x.x.x. The problem is that the OUTPUT chain cannot be used with the target SNAT! Has anybody any idea about which is the best and simplest way to get the result described above?

Thanks for Your collaboration.
Monia Cheli

Tiscali ADSL 4 Mega Flat

Quoted 11 lines

Naviga senza limiti a 19,95 Euro al mese con 4 Megabps di velocita'. Attiva subito: hai 2 MESI di canone adsl GRATIS!

In piu', se sei raggiunto dalla rete Tiscali, telefoni senza pagare il canone Telecom.

Scopri subito come risparmiare!

http://abbonati.tiscali.it/prodotti/adsl/tc/4flat/

You do SNAT in POSTROUTING. Local generated packets also enter POSTROUTING. You may want to match source ip or .. you can mark packets in mangle OUTPUT, and then SNAT in POSTROUTING matching only the mark value with mark match.