Using mangle table to change source address, how?
I have an interface eth1, with an IP address 192.168.23.100
I've configured eth1 to have a subinterface eth1:0, and have given that subinterface an IP address 172.23.1.3.
There is a host on the segment that this interface is connected to with an IP address of 172.23.1.2.
If I send packets to that host 172.23.1.2, the packets from me have a source address of 192.168.23.100, not 172.23.1.3!
Can I use the mangle table to rewrite the source address? If so, what is the iptable command line?
Or is there an easier way?
Signature · 3 lines
Mark Atwood | Well done is better than well said. [email protected] | http://www.pobox.com/~mra
Quoted 8 lines · Mark Atwood
I have an interface eth1, with an IP address 192.168.23.100
I've configured eth1 to have a subinterface eth1:0, and have given that subinterface an IP address 172.23.1.3.
There is a host on the segment that this interface is connected to with an IP address of 172.23.1.2.
Quoted 7 lines
If I send packets to that host 172.23.1.2, the packets from me have a source address of 192.168.23.100, not 172.23.1.3!
Can I use the mangle table to rewrite the source address? If so, what is the iptable command line?
Or is there an easier way?
Use the nat table - that's what it's for.
eg
iptables -A POSTROUTING -t nat -d 172.23.1.2 -j SNAT --to 172.23.1.3
Antony.
Signature · 2 lines
Normal people think "if it ain't broke, don't fix it". Engineers think "if it ain't broke, it doesn't have enough features yet".
Quoted 8 lines · Mark Atwood
I have an interface eth1, with an IP address 192.168.23.100
I've configured eth1 to have a subinterface eth1:0, and have given that subinterface an IP address 172.23.1.3.
There is a host on the segment that this interface is connected to with an IP address of 172.23.1.2.
Quoted 7 lines
If I send packets to that host 172.23.1.2, the packets from me have a source address of 192.168.23.100, not 172.23.1.3!
Can I use the mangle table to rewrite the source address? If so, what is the iptable command line?
Or is there an easier way?
It would be the NAT table, postrouting chain, not mangle. something like:
/sbin/iptables -t nat -A POSTROUTING -d 172.23.1.2 -j SNAT --to-source 172.23.1.3
j