centos 7 端口转发

1. 安装rinetd

# 如果没有安装gcc 先安装gcc,这里就全部一并安装了
yum -y install gcc+ gcc-c++
yum -y install make
#安装,如果地址失效,去官网查看下载地址即可
wget https://boutell.com/rinetd/http/rinetd.tar.gz
tar -zxf rinetd.tar.gz 
mkdir -p /usr/man/man8
make && make install
# 配置
vim /etc/rinetd.conf
# 一行即为一条转发规则 格式如:[source_address] [source_port] [destination_address] [destination_port]
#[本机IP(若非多网卡直接设为0.0.0.0)] [转发端口] [服务IP] [服务端口]
#我本次转发的端口是hbase的即为
192.168.9.87 16000 172.17.0.2 16000
192.168.9.87 16010 172.17.0.2 16010
#启动
rinetd -c /etc/rinetd.conf
#停止 直接kill 即可
#查看转发
netstat -tanulp|grep rinetd

2.使用iptables 转发

这种方式没有试,因为我自己机器,把防火墙关闭了,所以没有使用这种方式。

猜你喜欢

转载自www.cnblogs.com/xiaopan-cp9/p/10874253.html