Source NAT
Hello,
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
For example
if dst = 1.1.1.1 src = 10.1.1.1
if dst = 1.1.2.1 src = 10.1.1.2
Can anyone give me any advice on completing that?
Regards,
Quoted 12 lines · Jimmy
Hello,
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
For example
if dst = 1.1.1.1 src = 10.1.1.1
if dst = 1.1.2.1 src = 10.1.1.2
You can use DNAT
for exemple:
iptables -t nat -A PREROUTING -s 1.1.1.1 -j DNAT --to-destination10.1.1.1
Quoted 9 lines
Can anyone give me any advice on completing that?
Regards,
Quoted 14 lines · Stéphane BENOLIEL
Quoted 12 lines · Jimmy
Hello,
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
For example
if dst = 1.1.1.1 src = 10.1.1.1
if dst = 1.1.2.1 src = 10.1.1.2
Quoted 6 lines
You can use DNAT
for exemple:iptables -t nat -A PREROUTING -s 1.1.1.1 -j DNAT
--to-destination10.1.1.1
sorry.... mistmach...... the good solution is :
iptables -t nat -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination10.1.1.1
Quoted 10 lines
Quoted 9 lines
Can anyone give me any advice on completing that?
Regards,
Quoted 3 lines · Jimmy
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
Trivial.
Quoted 1 line
if dst = 1.1.1.1 src = 10.1.1.1
iptables -vt nat -A POSTROUTING -d 1.1.1.1 -j SNAT -to 10.1.1.1
Quoted 1 line
Can anyone give me any advice on completing that?
"man iptables"
Order matters. If you have a catchall SNAT rule before the specific destination ones, the catchall is the one used.
NAT != routing. If your SNAT'ed IP addresses need to go out different interfaces, this won't work. See the LARTC HOWTO.
Signature · 2 lines
mail to this address is discarded unless "/dev/rob0"
or "not-spam" is in Subject: header-----Original Message-----
From: /dev/rob0 <[email protected]>
To: [email protected]
Date: Wed, 31 Aug 2005 06:37:33 -0500
Subject: Re: Source NAT
Quoted 10 lines · Jimmy
Quoted 3 lines
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
Trivial.
Quoted 1 line
if dst = 1.1.1.1 src = 10.1.1.1
iptables -vt nat -A POSTROUTING -d 1.1.1.1 -j SNAT -to 10.1.1.1
why -vt?
this rule confused me, I'm a begginer;
what about
iptables -t nat -A POSTROUTING -s 10.1.1.1/24 -j SNAT --to 1.1.1.1
or
iptables -t nat -A POSTROUTING -o eth0 -s 10.1.1.1/24 -j SNAT --to 1.1.1.1
Quoted 13 lines
Quoted 2 lines
Can anyone give me any advice on completing that?
"man iptables"
Order matters. If you have a catchall SNAT rule before the specific destination ones, the catchall is the one used.
NAT != routing. If your SNAT'ed IP addresses need to go out different interfaces, this won't work. See the LARTC HOWTO.
Signature · 2 lines
mail to this address is discarded unless "/dev/rob0" or "not-spam" is in Subject: header
Quoted 6 lines · ISC Jorge Ceron Galvan
Quoted 6 lines
Quoted 3 lines
I currently have a situation that I am hoping iptables can resolve. The issue is that I need to NAT the source address based on the destination address. Is that possible with IPTables ?
Trivial.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
if dst = 1.1.1.1 src = 10.1.1.1
iptables -vt nat -A POSTROUTING -d 1.1.1.1 -j SNAT -to 10.1.1.1
why -vt?
this rule confused me, I'm a begginer;
All the more reason to RTFM, as previously suggested. Hint: the -v option to iptables does the same thing as does the -v option to most other command line programs.
Quoted 3 lines
what about
iptables -t nat -A POSTROUTING -s 10.1.1.1/24 -j SNAT --to 1.1.1.1
This is not what the OP said was wanted. That is SNAT based on the source address, not the destination.
Quoted 2 lines
iptables -t nat -A POSTROUTING -o eth0 -s 10.1.1.1/24 -j SNAT --to 1.1.1.1
Same thing, with the additional specification of output interface. You can, of course, specify more matching options to limit the packets selected by the rule. It *is* common to limit SNAT based upon source address too.
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Can anyone give me any advice on completing that?
"man iptables"
Order matters. If you have a catchall SNAT rule before the specific destination ones, the catchall is the one used.
NAT != routing. If your SNAT'ed IP addresses need to go out different interfaces, this won't work. See the LARTC HOWTO.
Signature · 2 lines
mail to this address is discarded unless "/dev/rob0"
or "not-spam" is in Subject: header