Solved Redirect another IP TS3server - IPTABLES

zhaiks

Active Member
Sep 17, 2016
42
1
80
i would like redirect all traffic from this IP: XXXport: 9990 - to this ts3 server ip: XXXX:9987

I would like it when users connect to this server XXX:9990 automatically redirect it to the main XXXX: 9987..

what should i configure in the server XXX with iptables - I Have ubuntu 14.04 lts

Edit by mod: IPs hidden
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Hello try this

Assuming that 192.168.1.100 is source IP address and 192.168.1.101 is destination
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p udp --dport 9990 -j DNAT --to-destination 192.168.1.101:9987
iptables -t nat -A POSTROUTING -p udp -d 192.168.1.101 --dport 9987 -j SNAT --to-source 192.168.1.100
 

vipiris

New Member
Aug 24, 2017
1
1
18
Hello try this

Assuming that 192.168.1.100 is source IP address and 192.168.1.101 is destination
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p udp --dport 9990 -j DNAT --to-destination 192.168.1.101:9987
iptables -t nat -A POSTROUTING -p udp -d 192.168.1.101 --dport 9987 -j SNAT --to-source 192.168.1.100

I test this and works.
 

zhaiks

Active Member
Sep 17, 2016
42
1
80
Hello try this

Assuming that 192.168.1.100 is source IP address and 192.168.1.101 is destination
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p udp --dport 9990 -j DNAT --to-destination 192.168.1.101:9987
iptables -t nat -A POSTROUTING -p udp -d 192.168.1.101 --dport 9987 -j SNAT --to-source 192.168.1.100
Thanks bro you are amazing
 

chuga2

Restricted
Jul 16, 2016
175
42
61
Hello try this

Assuming that 192.168.1.100 is source IP address and 192.168.1.101 is destination
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p udp --dport 9990 -j DNAT --to-destination 192.168.1.101:9987
iptables -t nat -A POSTROUTING -p udp -d 192.168.1.101 --dport 9987 -j SNAT --to-source 192.168.1.100

how can redirect the server to another server but for port query 10011??
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Not sure but probably changing protocol to tcp and source / destination ports could do the thing
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
For example
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p tpc --dport 10011-j DNAT --to-destination 192.168.1.101:10011
iptables -t nat -A POSTROUTING -p tpc -d 192.168.1.101 --dport 10011 -j SNAT --to-source 192.168.1.100
 
Last edited:

chuga2

Restricted
Jul 16, 2016
175
42
61
For example
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p tpc --dport 10011-j DNAT --to-destination 192.168.1.101:10011
iptables -t nat -A POSTROUTING -p tpc -d 192.168.1.101 --dport 10011 -j SNAT --to-source 192.168.1.100
is not working :confused:
 

dumpmyself

Member
Mar 20, 2016
15
0
38
-p tpc?

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward



iptables -t nat -A PREROUTING -p tcp --dport 10011-j DNAT --to-destination 192.168.1.101:10011

iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.101 --dport 10011 -j SNAT --to-source 192.168.1.100
 

chuga2

Restricted
Jul 16, 2016
175
42
61
-p tpc?

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward



iptables -t nat -A PREROUTING -p tcp --dport 10011-j DNAT --to-destination 192.168.1.101:10011

iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.101 --dport 10011 -j SNAT --to-source 192.168.1.100
I saw it and i changed it but is not worked
 
Last edited:

dumpmyself

Member
Mar 20, 2016
15
0
38
Try now sorry
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward



iptables -t nat -A PREROUTING -p tcp --dport 10011 -j DNAT --to-destination 192.168.1.101:10011

iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.101 --dport 10011 -j SNAT --to-source 192.168.1.100
 
Top