CentOS系统中使用iptables设置端口转发
来源:互联网 发布:nba历届得分王及数据 编辑:程序博客网 时间:2024/04/27 05:53
将本地接口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
(主要访问到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
0 0
- CentOS系统中使用iptables设置端口转发
- CentOS系统中使用iptables设置端口转发
- iptables设置端口转发
- centos iptables 端口转发命令
- CENTOS7使用iptables端口转发
- iptables之NAT端口转发设置
- centos 6.5 系统中iptables防火墙开放端口
- CentOS 6.5系统中iptables防火墙开放端口
- Centos技术(3)--CentOS 6.5系统中iptables防火墙开放端口80 3306 22端口
- CentOS下iptables设备双网卡的端口转发规则
- iptables 端口转发实例
- iptables 实现端口转发
- iptables进行端口转发
- iptables 做端口转发
- iptables 端口转发
- iptables 做端口转发
- iptables 配置端口转发
- iptables 实现端口转发
- 使用xml属性 改变控件的样式和渐变色
- 在windows操作系统中打开远程桌面的命令--mstsc
- LeetCode 97(Interleaving String)Java
- T语言与快速开发平台之天宇联iOS开发手册
- 继承 接口 抽象
- CentOS系统中使用iptables设置端口转发
- linux内核TCP相关参数解释【转】
- PHP 全局变量 - 超全局变量
- H5知识 -- meta篇
- T语言与快速开发平台之天宇联web前端开发指南
- 这世上最纠缠不清的一对情人
- HDU 1269:迷宫城堡 (Tarjan强连通分量)
- VMware Workstation 12下载安装与激活图文教程
- Extjs-行编辑器 Ext.ux.grid.RowEditor()