Portal Home > Knowledgebase > Articles Database > Iptables Forward packets


Iptables Forward packets




Posted by PickleHosting, 05-04-2013, 04:17 AM
So the situation is we're having issues forwarding packets from a certain IP on a server. This is what is happening so far. 1. Main server IP - 1.1.1.1 2. Secondary IP (what we want the client ot connec to) - 2.2.2.2:2000 3. Destination IP (where the secondary ip shoudl be forwardding packets to) - 3.3.3.3:2000 So when we set up the iptables rules as follows: with this as well: It routes the packets fine to the correct port BUT notn from the 2.2.2.2 address it's routing it from 1.1.1.1. Putting in source into the POSTROUTING section as "-s 2.2.2.2" stops the routing and it doesn't work any longer. So I'm unsure how to get it forwarding FROM the ip we want (secondary IP). Cheers.

Posted by ClaudiuPopescu, 05-04-2013, 05:55 PM
Stop using MASQUERADE and start using SNAT: iptables -t nat -A POSTROUTING -s $IP -o ethX -j SNAT --to-source 2.2.2.2 Replace $IP with your internal IP which you need to route through 2.2.2.2. Masquerade will route all your outgoing traffic through the main server IP. At least in your current configuration. This might help: http://www.netfilter.org/documentati...T-HOWTO-6.html

Posted by RoseHosting, 05-04-2013, 10:44 PM
You can use rinetd, which redirects TCP connections from one IP address and port to another.

Posted by ovais, 05-05-2013, 06:01 AM
1 for Rinetd takes only 1-2 minute to setup.

Posted by Infinitnet, 05-05-2013, 06:32 AM
Another alternative for TCP tunneling would be "redir", although I'd stick with iptables. POSTROUTING with SNAT will do what you want.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Server Centre Limited (Views: 793)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.