Sign in to follow this  
Followers 0

guide Proxy for l2off and l2j server on Centos7

1 post in this topic

Posted (edited) · Report post

Redirecting Network Traffic To A New IP Using IPtables

By using iptables and its masquerade feature, it is possible to forward all traffic to the old server to the new IP.

This tutorial will show which command lines are required to make this possible.


In this article, it is assumed that you do not have iptables running, or at least no nat table rules for chain PREROUTING and POSTROUTING.

The first thing to do is do enable IP forwarding. This is done either by using:


# echo "1" > /proc/sys/net/ipv4/ip_forward


# sysctl net.ipv4.ip_forward=1

Then, we will add a rule telling to forward the traffic on port 1111 to ip on port 1111:

# iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination

and finally, we ask IPtables to masquerade:

iptables -t nat -A POSTROUTING -j MASQUERADE

Optionally, you could only redirect the traffic from a specific source/network with, for a host only:

# iptables -t nat -A PREROUTING -s -p tcp --dport 1111 -j DNAT --to-destination

or for a whole network

# iptables -t nat -A PREROUTING -s -p tcp --dport 1111 -j DNAT --to-destination

that's it, now the traffic to port 1111 will be redirected to IP .
If you go on host, you should see a lot of traffic coming from the host doing the redirection.


For L2off server use this ports:

 iptables -t nat -A PREROUTING -p tcp --dport 2106 -j DNAT --to-destination
 iptables -t nat -A PREROUTING -p tcp --dport 7777 -j DNAT --to-destination


Edited by Network

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0