Shadowsocks利用 Socat 实现单端口 中继(中转/端口转发)加速
来源:互联网 发布:淘宝达人佣金给多少 编辑:程序博客网 时间:2024/05/18 21:07
Shadowsocks利用 Socat 实现单端口 中继(中转/端口转发)加速
使用场景:服务器之间的中转。
优点:支持 TCP/UDP 转发。
缺点:不支持端口段(多个端口需要开启多个转发)
Socat安装
Centos 系统:
yum install -y socat
Debian/Ubuntu 系统:
apt-get updateapt-get install -y socat
Socat使用
转发TCP
nohup socat TCP4-LISTEN:2333,reuseaddr,fork TCP4:233.233.233.233:6666 >> /root/socat.log 2>&1 &
转发UDP
nohup socat UDP4-LISTEN:2333,reuseaddr,fork UDP4:233.233.233.233:6666 >> /root/socat.log 2>&1 &
nohup指的是 后台运行。
TCP4-LISTEN:2333 指的是 监听ipv4的端口,也就是 转发的端口,后面Shadowsocks链接中继时填写的 端口,中继服务器。
fork TCP4:233.233.233.233:6666 指的是 被转发的 IP 和 端口,也就是你要中继的服务器的 IP 和 端口,被中继的服务器。
/root/socat.log 2>&1 & 指的是 转发日志记录。
停止转发
ps -ef | grep socat#输入上面的命令找到socat程序的PID,然后用下面的命令KILL掉这个PID进程(PID是个数字,自己替换下面的"pid")。kill -9 pid
Socat卸载
Centos系统:
yum remove socat
Debian/Ubuntu系统:
sudo apt-get remove socatsudo apt-get autoremove
防火墙设置
如果你设置后无法链接,那么多半是防火墙 阻拦了,只要开放端口 就行了。以上面的 示例的中继端口 2333 为例。
iptables -I INPUT -p tcp --dport 2333 -j ACCEPTiptables -I INPUT -p udp --dport 2333 -j ACCEPT
保存防火墙
service iptables save 或/etc/init.d/iptables save
重启防火墙
service iptables restart 或/etc/init.d/iptables restart
开机启动
Centos系统:
chmod +x /etc/rc.d/rc.localvi /etc/rc.d/rc.local
Ubuntu/Debian系统:
chmod +x /etc/rc.localvi /etc/rc.local
输入 I 键 进入编辑模式(如果没反应请看上面的教程安装 vim),然后在打开的文件中的 exit 0 代码前面插入你的 socat 命令代码(就是上面 nohup socat…的代码)。
原文地址:http://biyongyao.com/archives/221
阅读全文
0 0
- Shadowsocks利用 Socat 实现单端口 中继(中转/端口转发)加速
- socat端口转发-穿透网络
- 利用ssh端口转发实现邮件转发
- centos端口转发神器:socat安装及使用
- socat 内网端口转发 并后台运行
- 利用SSH端口转发功能实现X转发
- iptables 实现端口转发
- Linux实现端口转发
- iptables 实现端口转发
- 利用iptables 做端口转发
- linux 利用iptables 端口转发
- 利用ssh的端口转发实现SOCKS5代理
- linux rinetd、socat端口转发部署(很实用的网络工具)
- 利用Apache端口转发实现虚拟主机服务器php+jsp共用80端口
- linux 实现 端口转发【详细】
- 配置iptables实现端口转发
- SSH端口转发实现代理服务器
- 应用netcat实现端口转发
- Raid0、 Raid1、 Raid5、 Raid10
- Java_6
- Kaggle赛题-Synthetic Financial Datasets For Fraud Detection
- 前端开发学习流程
- 深入了解Android蓝牙Bluetooth——《进阶篇》
- Shadowsocks利用 Socat 实现单端口 中继(中转/端口转发)加速
- SF6项目——Login
- Lucene 深入学习(1)全文检索
- php缓冲区探析
- 关于scanf的问题
- 使用Servlet上传多张图片——访问提示
- Windows / Ubuntu操作系统下Pixhawk原生固件PX4的编译方法
- 语音识别原理
- 深入了解Android蓝牙Bluetooth——《基础篇》