I tried to understand the concept of iptables mangling part, but somehow failed to understand the IP header manipulative section.

For example: Below is the system scenario which I'm trying to correlate with the iptables.

We have an application which holds one IP (IP1 - pool 1) for all incoming and outgoing packets. Now, we need to define new interface IP against different POOL (IP2 - POOL2)for particular incoming/outgoing traffic need)

Need for an IPTABLE mangle :

We need IPtables to perform the below actions:

PREROUTING: if the packet destination is IP2, then we need a "iptable mangle rule" to modify the destination address from IP2 to IP1 and leave the packet (so that packet will go the application and IP2 address behaves as forward IP on different interface & pool than IP1).

Query :

Is it possible to add one rule to achieve the above action? , if yes, could someone provide hint or pointer to frame one ?

Thanks in Advance.

  • Why can't the application listen on both IPs? That would be an easier solution than NATing the packet over to the other IP. – Andrew Domaszek Dec 1 '14 at 22:51
  • Your question isn't very clear. What you are asking doesn't make a lot of sense. You want to modify the destination, without actually changing the destination? – Zoredache Dec 1 '14 at 23:45
  • @AndrewDomaszek Yes, but application is too legacy and can't bound two IPs to listen. So only need NAT help to just fake the packet routing and also we need to measure the traffic on pool2 – Snake Dec 2 '14 at 7:44
  • @Zoredache I'm not getting what you mean by "without actually changing the destination" if you mean without adding the IP to actual application, then yes. We don't want to bind two IP to listen instead we want NAT the destination IP to the existing one. – Snake Dec 2 '14 at 7:46
  • Maybe in simple term, if incoming packet destination IP (PRE) is X then I want to modify it to Y using iptables and also if the outgoing packet address is Y then like to change it to X (POST).Thanks in Advance. – Snake Dec 2 '14 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.