How to redirect ip address using iptables

I have a small local network with 5 computers. My ISP gave me my real IP address (194.187 ...), but computers on the network cannot see it. So I need to do a redirect on my router (using a Linux system) that will redirect the real IP address (194.187 ...) to the IP address I have on the provider's network (10.12.205.26).

How can I accomplish this using iptables on my router. Thank.

+3


source to share


1 answer


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...

      

+2


source







All Articles