一、使用rinted进行端口转发

将10.50.13.13 80请求转到10.50.13.11 80上

1、安装rinetd

$ tar zxf rinetd.tar.gz
$ cd rinetd
$ make
$ make install

2、编辑配置文件

$ vi /etc/rinetd.conf  添加如下内容
$ 0.0.0.0 80 10.50.13.11 80  #本机IP为10.50.13.13

3、启动rinetd服务

$ rinetd -c /etc/rinetd.conf

二、使用iptables进行端口转发

将10.50.13.13 80请求转到10.50.13.11 80上,配置如下:

iptables -t nat -A PREROUTING -d 10.50.13.13 -p tcp --dport 80 -j DNAT --to-destination 10.50.13.11:80
iptables -t nat -A POSTROUTING -s 0.0.0.0/0 -p tcp --dport 80 -j SNAT --to-source 10.50.13.13
/etc/init.d/iptables save
echo 1 > /proc/sys/net/ipv4/ip_forward  #打开路由转发功能

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-01-27
  • 2021-08-23
  • 2021-07-27
猜你喜欢
  • 2021-11-19
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案