最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

CentOS系统中使用iptables设置端口转发

来源:动视网 责编:小采 时间:2020-11-09 13:46:22
文档

CentOS系统中使用iptables设置端口转发

CentOS系统中使用iptables设置端口转发:将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389 (主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389) 【步骤】 1、 首先应该做的是/etc/sysctl.conf配置文件的 net.ipv4.ip_forward =
推荐度:
导读CentOS系统中使用iptables设置端口转发:将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389 (主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389) 【步骤】 1、 首先应该做的是/etc/sysctl.conf配置文件的 net.ipv4.ip_forward =


将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389 (主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389) 【步骤】 1、 首先应该做的是/etc/sysctl.conf配置文件的 net.ipv4.ip_forward = 1 默认是0 这样允许iptalbes FORWARD

  将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389

  (主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389)

  【步骤】

  1、 首先应该做的是/etc/sysctl.conf配置文件的 net.ipv4.ip_forward = 1 默认是0 这样允许iptalbes FORWARD。

  2、 service iptables stop 关闭防火墙

  3、 重新配置规则

  iptables -t nat -A PREROUTING --dst 61.144.14.72 -p tcp --dport 3389 -j DNAT --to-destination 116.6.73.229:3389

  iptables -t nat -A POSTROUTING --dst 116.6.73.229 -p tcp --dport 3389 -j SNAT --to-source 61.144.14.72

  service iptables save

  将当前规则保存到 /etc/sysconfig/iptables

  若你对这个文件很熟悉直接修改这里的内容也等于命令行方式输入规则。

  5、 启动iptables 服务, service iptables start

  可以写进脚本,设备启动自动运行;

  # vi /etc/rc.local

  #!/bin/sh

  #

  # This script will be executed *after* all the other init scripts.

  # You can put your own initialization stuff in here if you don't

  # want to do the full Sys V style init stuff.

  touch /var/lock/subsys/local

  sh /root/myshipin.log

  ---------------------------------------------------------------------

  vi myshipin.log

  #!/bin/sh

  #

  # This script will be executed *after* all the other init scripts.

  # You can put your own initialization stuff in here if you don't

  # want to do the full Sys V style init stuff.

  iptables -F -t nat iptables -t nat -A PREROUTING --dst 61.144.14.72 -p tcp --dport 3389 -j DNAT --to-destination 116.6.73.229:3389

  iptables -t nat -A POSTROUTING --dst 116.6.73.229 -p tcp --dport 3389 -j SNAT --to-source 61.144.14.72

  ~

  ----------------------------------------------------------------

  TCP

  iptables -t nat -A PREROUTING --dst 61.144.14.87 -p tcp --dport 9304 -j DNAT --to-destination 10.94.143.204:9304

  iptables -t nat -A POSTROUTING --dst 10.94.143.204 -p tcp --dport 9304 -j SNAT --to-source 61.144.14.87

  UDP

  iptables -t nat -A PREROUTING --dst 61.144.14.87 -p udp --dport 9305 -j DNAT --to-destination 10.94.143.204:9305

  iptables -t nat -A POSTROUTING --dst 10.94.143.204 -p udp --dport 9305 -j SNAT --to-source 61.144.14.87

文档

CentOS系统中使用iptables设置端口转发

CentOS系统中使用iptables设置端口转发:将本地接口IP 61.144.14.72 的3389端口 转发到 116.6.73.229的3389 (主要访问到61.144.14.72的3389端口,就会跳转到116.6.73.229的3389) 【步骤】 1、 首先应该做的是/etc/sysctl.conf配置文件的 net.ipv4.ip_forward =
推荐度:
标签: 设置 转发 使用
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top