Difference between revisions of "Tunnelling UDP Traffic Through An SSH Connection"

From NST Wiki
Jump to navigationJump to search
(Use: "'''nc'''" To Translate UDP To TCP On The Local Side)
(Tunnel A TCP Forward Port Through SSH)
Line 21: Line 21:
 
</div>
 
</div>
  
In this example '''SSH''' traffic is being '''NATed''' through a firewall. The '''SSH''' filtered port at the ''dirty'' side of the firewall is: "'''31222'''". We have chosen to use '''TCP''' port forwarding for the "'''''non-used'''''" '''TCP''' port: "'''9999'''". The remote '''NST''' probe's '''IP Address''' is: "'''55.44.22.178'''". On the ''local'' '''NST''' probe, '''TCP''' port: "'''9999'''" is bound to the '''localhost IP Address''': "'''127.0.0.1'''".
+
In this example '''SSH''' traffic is being '''NATed''' through a firewall. The '''SSH''' filtered port at the ''dirty'' side of the firewall is: "'''31222'''". We have chosen to use '''TCP''' port forwarding for the "'''''non-used'''''" '''TCP''' port: "'''9999'''". The remote '''NST''' probe's '''IP Address''' is: "'''55.44.22.178'''". On the ''local'' '''NST''' probe, '''TCP''' port: "'''9999'''" is bound to the '''localhost''' ('''IP Address''': "'''127.0.0.1'''").
  
 
== Use: "'''nc'''" To Translate TCP To UDP On The SSH Server Side ==
 
== Use: "'''nc'''" To Translate TCP To UDP On The SSH Server Side ==

Revision as of 20:12, 22 March 2007

Overview

This section describes how to use NST to tunnel a UDP traffic conversation through a SSH connection. For our example we will tunnel IPMItool traffic (UDP Port: "623") through an SSH connection to a Sun Fire X4200 server's Integrated Lights Out Manager (ILOM) service processor network interface. Three systems are involved, 2 NST probes and the X4200 server. Reference information was taken from: "Performing UDP tunneling through an SSH connection".

Step By Step Instructions:

Tunnel A TCP Forward Port Through SSH

First we need to establish the tunnel for a "non-used" TCP port from the local NST probe to the remote NST probe SSH server which shares the same LAN as the destination X4200 server.

Establish An SSH Connection With TCP Port Forwarding
[root@probe tmp]# /usr/bin/ssh -p 31222 -L 9999:localhost:9999 root@55.44.22.178;
root@55.44.22.178's password:
Last login: Thu Mar 22 11:18:59 2007 from cpe-72-222-76-188.nycaper.res.rdr.com

===============================================
= Linux Network Security Toolkit (NST v1.5.0) =
===============================================

[root@probe-biostar ~]#

In this example SSH traffic is being NATed through a firewall. The SSH filtered port at the dirty side of the firewall is: "31222". We have chosen to use TCP port forwarding for the "non-used" TCP port: "9999". The remote NST probe's IP Address is: "55.44.22.178". On the local NST probe, TCP port: "9999" is bound to the localhost (IP Address: "127.0.0.1").

Use: "nc" To Translate TCP To UDP On The SSH Server Side

On the remote NST probe (SSH server side), we need to open a port listener for TCP port: "9999" and translate all network traffic to UDP port: "623" for the IP Address assigned to the X4200 server's ILOM network interface.

We will first need to create a "fifo". The "fifo" will be necessary to maintain a two-way communication channel between the TCP port listener and the ILOM UDP port. A simple shell pipe would NOT work. It would only communicate left process' standard output to right process' standard input. We will use the Linux command: "mkfifo" to establish the "fifo".

FIFO Creation - Remote Side
[root@probe-biostar ~]# /usr/bin/mkfifo "/tmp/fifo";
[root@probe-biostar ~]# /bin/ls -al "/tmp/fifo";
prw-r--r-- 1 root root 0 Mar 22 19:37 /tmp/fifo
[root@probe-biostar ~]#


Next we will use "nc" (netcat) the "TCP/IP Swiss Army Knife" to perform the TCP/IP to UDP translation.

TCP To UDP Network Traffic Translation Using: "nc"
[root@probe-biostar ~]# /usr/bin/nc -l 9999 < "/tmp/fifo" | /usr/bin/nc -u 172.19.1.28 623 > "/tmp/fifo";

This command sequence will allow all TCP traffic on the remote NST probe for port: "9999" to be forwarded using the UDP network protocol to the X4200 server's ILOM network interface: 172.19.1.28, UDP port: "623" and receive network traffic responses back.

Use: "nc" To Translate UDP To TCP On The Local Side

Once again we will need to create a "fifo" and use the "nc" networking utility for protocol translation. The following output shows the "fifo" creation on the local side where we will run the "IPMItool" command.

FIFO Creation - Local Side
[root@probe ~]# /usr/bin/mkfifo "/tmp/fifo";
[root@probe ~]# /bin/ls -al "/tmp/fifo";
prw-r--r-- 1 root root 0 Mar 22 19:37 /tmp/fifo
[root@probe ~]#


Now perform the UDP to TCP/IP translation using: "nc".

UDP To TCP Network Traffic Translation Using: "nc"
[root@probe ~]# /usr/bin/nc -l -u 623 < "/tmp/fifo" | /usr/bin/nc 127.0.0.1 9999 > "/tmp/fifo";

This command sequence will allow all UDP traffic on the local NST probe for port: "623" (the default ILOM UDP port value) to be forwarded using the TCP network protocol to the localhost (IP Address: "127.0.0.1") listening TCP port: "9999" and receive network traffic responses back. The listening TCP port: "9999" was established during the SSH setup above.