如何使用iptables重定向IP地址 [英] How to redirect ip address using iptables

查看:1196
本文介绍了如何使用iptables重定向IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5台计算机的小型局域网.我的提供者给了我真实的IP地址(194.187 ...),但是网络中的计算机看不到它.因此,我必须在路由器(使用linux系统)上进行重定向,这会将真实IP地址(194.187 ...)重定向到我在提供商网络中拥有的IP地址(10.12.205.26).

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

如何使用路由器上的iptables执行此操作.谢谢.

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

推荐答案

我希望这对您有用:

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

这篇关于如何使用iptables重定向IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆