端口映射工具 redir/socat/xinetd
2014-05-08 13:49
465 查看
NAT网关,通常用iptables实现,但性能很差不适合用于生产环境。可通过硬件设备或小米开源的dsnat完成。
端口映射的需求也常有,通过也是用iptables实现。可是iptables太重,性能是个大问题,且每次更新都需要重启。
此时,我们需要一个工具来实现端口映射。如果纯粹是HTTP协议,那么直接用Nginx即可。像MySQL、MongoDB之类则不适用。Google一翻,答案知晓:redir、socat。
其中 redir 只支持TCP协议,但使用非常简单。比如将外网的2669端口映射对内网1台MySQL服务器,一键搞定:
还有一点高级功能就去自行查阅帮助吧。
socat则更强大,支持ipv4、ipv6、tcp、udp、unix-socks、socket等等了。出于“The simpler the better”的观念,恭喜redir入围!
如果映射量比较大,需要易维护、搞攻击,就必须想到xinted了。配置 /etc/xinetd.d/mysql-portmap 如下:
每个映射可以有独立配置文件来管理,修改只需要reload即可!当受到攻击时,在系统日志 /var/log/messages 中会看到:
xinetd[26269]: Starting reconfiguration xinetd[26269]: Swapping defaults
xinetd[26269]: readjusting service rsync xinetd[26269]: service mysql-portmap deactivated
xinetd[26269]: mysql-portmap: svc_release with 0 count xinetd[26269]: Reconfigured: new=1 old=1 dropped=1 (services)
xinetd[26269]: Deactivating service mysql-portmap due to excessive incoming connections. Restarting in 10 seconds. xinetd[26269]: Activating service mysql-portmap
用xinetd来管理端口映射简单太完美了!
端口映射的需求也常有,通过也是用iptables实现。可是iptables太重,性能是个大问题,且每次更新都需要重启。
此时,我们需要一个工具来实现端口映射。如果纯粹是HTTP协议,那么直接用Nginx即可。像MySQL、MongoDB之类则不适用。Google一翻,答案知晓:redir、socat。
其中 redir 只支持TCP协议,但使用非常简单。比如将外网的2669端口映射对内网1台MySQL服务器,一键搞定:
redir --lport=2669 --caddr=10.58.66.32 --cport=3306
还有一点高级功能就去自行查阅帮助吧。
socat则更强大,支持ipv4、ipv6、tcp、udp、unix-socks、socket等等了。出于“The simpler the better”的观念,恭喜redir入围!
如果映射量比较大,需要易维护、搞攻击,就必须想到xinted了。配置 /etc/xinetd.d/mysql-portmap 如下:
service mysql-portmap { id = 1 disable = no type = UNLISTED socket_type = stream protocol = tcp wait = no redirect = 10.33.66.88 3306 bind = 183.68.36.138 port = 2669 user = nobody group = nobody flags = NODELAY KEEPALIVE NOLIBWRAP IPv4 log_type = FILE /data/log/xinetd/tcp-portmap.log cps = 100 30 }
每个映射可以有独立配置文件来管理,修改只需要reload即可!当受到攻击时,在系统日志 /var/log/messages 中会看到:
xinetd[26269]: Starting reconfiguration xinetd[26269]: Swapping defaults
xinetd[26269]: readjusting service rsync xinetd[26269]: service mysql-portmap deactivated
xinetd[26269]: mysql-portmap: svc_release with 0 count xinetd[26269]: Reconfigured: new=1 old=1 dropped=1 (services)
xinetd[26269]: Deactivating service mysql-portmap due to excessive incoming connections. Restarting in 10 seconds. xinetd[26269]: Activating service mysql-portmap
用xinetd来管理端口映射简单太完美了!
相关文章推荐
- 端口映射工具 redir/socat/xinetd - 运维技术 - 开源中国社区
- 端口映射工具 redir/socat/xinetd
- 端口映射工具--socat
- linux下简单好用的端口映射转发工具rinetd 转
- Linux下端口映射工具RINETD
- vIDC2.0 端口映射工具
- WlMAP:突破内网端口转发映射工具
- 内网端口映射工具
- 内网端口映射工具之80端口映射和全端口映射及辅助发布网站应用
- 端口映射工具:ngrok的使用(可用于本地测试微信)
- linux下简单好用的端口映射转发工具rinetd
- 写了一个端口映射工具, 代码贴出来下
- 外网端口映射工具之80端口映射发布网站应用
- 静态端口映射工具
- centos6.7 安装端口映射工具 rinetd
- linux下简单好用的端口映射转发工具rinetd
- 端口映射提速工具PortTunnel用法
- linux下简单好用的端口映射转发工具rinetd 转
- 使用socat做端口映射
- P2P端口映射开源工具:狗洞(dog-tunnel)安装脚本