How to redirect ip address using iptables [closed]

2020-06-06 01:32发布

I have small local network with 5 computers. My provider gave me real ip address (194.187...), but computers in the network cannot see it. So I have to make redirect on my router (with linux system), which will redirect real ip address (194.187...) to ip address which I have in provider's network (10.12.205.26).

How can I perform this with iptables on my router. Thanks.

1条回答
欢心
2楼-- · 2020-06-06 02:27

I Hope this works for you :

   Add (prerouting,postrouting) rules in you NAT table using

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source ip_address
iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-destination ip_address

    and then use :

    iptables -t nat -A PREROUTING -d 194.187... -j DNAT --to-destination 10.12.205.26

    iptables -t nat -A POSTROUTING -s 10.12.205.26 -j SNAT --to-source 194.187...
查看更多
登录 后发表回答