开发者

How do I tunnel udp over ssh?

开发者 https://www.devze.com 2023-03-24 01:52 出处:网络
I\'m working on a Java application that collects various bits of information on network devices.All these devices are behind a network bastion, and I use JSch to create TCP tunnels to the remote devic

I'm working on a Java application that collects various bits of information on network devices. All these devices are behind a network bastion, and I use JSch to create TCP tunnels to the remote devices on demand. This works well for protocols like TL1 that are TCP based. However I do find myself needing to collect SNMP data as well.

The bastion server I have access to is rather old and limited, and I don't have a lot of options to build a SNMP Proxy over there. My question is if the community knows a clean, reliable way of programmaticly establishing tunnels as needed. I've looked at solutions such as this one, but as I have thousands to potentially tens of thousands of possible ip addresses, a manual one-off method is n开发者_如何学Conviable. If need be, I'll push for a server capable of doing a robust snmp proxy, but I need to know there is no other way before I fight that battle.


The SSH protocol does not include anything for UDP forwarding.

So you need to run some program at the SSH server side which will send the UDP packets for you, and receive sent ones.

I don't know the SNMP details, but for simple cases you can simply start netcat or socat with an exec channel, sending the packets with by standard input/standard output.

I suppose something like this could do:

netcat -u server 161 

Or with socat:

socat STDIO UDP:server:161


to forward udp:server:3200 to current machine, do the following:

socat SYSTEM:"ssh server socat - udp\:127.0.0.1\:3200" udp-l:3200,fork,reuseaddr

note that udp port 3200 on surver must be open and listend on, before using the tunnel.

0

精彩评论

暂无评论...
验证码 换一张
取 消