惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
B
Blog RSS Feed
小众软件
小众软件
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
博客园_首页
B
Blog
雷峰网
雷峰网
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
D
Docker
博客园 - 司徒正美
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
U
Unit 42
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
腾讯CDC
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
Jina AI
Jina AI
WordPress大学
WordPress大学
D
DataBreaches.Net
V
V2EX
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
P
Privacy & Cybersecurity Law Blog
F
Full Disclosure
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
The Hacker News
The Hacker News
Security Archives - TechRepublic
Security Archives - TechRepublic
IT之家
IT之家
P
Privacy International News Feed

Rat's Blog - 端口转发

Socat一键安装脚本,可转发TCP和UDP流量 - Rat's Blog Linux安装rinetd实现TCP端口转发,可加速网站 - Rat's Blog 使用iptables进行端口转发 - Rat's Blog Haproxy安装及端口转发配置 - Rat's Blog
使用socat进行单个端口的转发,同时支持tcp和udp - Rat's Blog
博主: Rat's · 2016-07-26 · via Rat's Blog - 端口转发

说明:由于用iptables经常不成功。所以只能寻求另一种办法,就是用socat工具来完成端口转发,如果你只有少数几个端口要转发的话,那么socat就是比较好的选择了。socat唯一麻烦的地方就是好像我没找到如何转发端口段,只能一个命令一个端口。不过如果只是自用转发少量端口的话还是蛮好用的。

socat安装

使用命令:

#CentOS系统
yum install -y socat

#Ubuntu或Debian系统
apt-get update
apt-get install -y socat

socat的使用

1、转发TCP

nohup socat TCP4-LISTEN:10000,reuseaddr,fork TCP4:1.1.1.1:10000 >> socat.log 2>&1 &

说明:

TCP4-LISTEN:10000监听ipv4的10000TCP端口。10000改成你自己需要转发的端口
fork TCP4:1.1.1.1:10000`转发到1.1.1.1的10000端口,根据需求修改自行修改ip和端口
nohup后台运行。可以把这个命令写到/etc/rc.local里面开机启动启动。

2、转发UDP

nohup socat -T 600 UDP4-LISTEN:10000,reuseaddr,fork UDP4:1.1.1.1:10000 >> socat.log 2>&1 &

很方便吧!把tcp改成udp就是转发udp了。说明如上。也可以直接写到/etc/local里面开机自动启动。


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/97/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。