Back to Home

Using SSH tunneling on Juniper devices with Junos

juniper · junos · ssh-tunnel · ssh

Using SSH tunneling on Juniper devices with Junos

    Given that the Junos operating system uses a fairly standard ssh daemon, I dared to suggest that it implemented ssh tunnels. And although the documentation about this use of switches, routers or firewalls could not find a mention - it works. Not only that, ssh tunnels are enabled by default.

    I will give an example to demonstrate where this can come in handy.

    Suppose, somewhere on a remote site, a new 3COM 3C16475CS switch is connected to a Juniper EX series switch under your control. And we are faced with the task of gaining control over the switch.

    From the documentation for 3C16475CSI managed to find out that the first time the device was turned on, the “Automatic IP Configuration” procedure is used to assign the ip address, during which the switch assigns an ip address from the 169.254.xy / 16 network. Where x and y are the last 2 bytes of the device’s MAC address. Since routing is not configured in the device (indeed, how can he know who on this network can be a router to other networks?), You can connect to the assigned ip only by having an ip address on the same network.

    For clarity, I will provide an explanatory diagram.


    The first thing we need to do is add an additional ip address belonging to the network 169.254.0.0/16 as the second address on the selected L3 interface of the Juniper EX 2200 switch.

    Second, make sure that the L3 interface we selected and the port to which the 3COM 3C16475CS switch is connected belong to the same VLAN.

    Here are excerpts from the configuration related to the first two points:
    adm @ ex2200> show configuration interfaces vlan
    unit 0 {
        family inet {
            address 192.168.77.8/24 {
                primary
            }
            address 169.254.20.20/16;
        }
    adm @ ex2200> show configuration vlans
    default {
        vlan-id 1;
        interface {
            ge-0/0 / 5.0;
        }
        l3-interface vlan.0;
    }
    

    Third, at the administrator’s workstation, we launch the ssh tunnel.
    > ssh -L 192.168.88.12:2000:169.254.1.2:80 192.168.77.8
    

    Fourth, we refer to the control interface of the 3COM switch at the URL http://192.168.88.12:2000/.

    PS: Since we are considering 3COM switches, I note that documentation on them can be found on the HP website using the so-called " 3Com product conversion tool ".

    PS1: This particular model of the 3C16475CS switch has one feature that spoils the simplicity of the solution. The fact is that the switch after user authentication changes the location for subsequent operation of the web interface. At the same time, it contains the ip address assigned by the switch. The location changes in the doCookie () function of the sysIpAddress variable. It is fixed as follows. After loading the user authentication window, but before the authentication itself, you can use the WEB developer tools (For example, in IE9. Alt-X Service, F12 Developer Tools, Script. Find the specified JavaScript function, variable). To change the variable, assign it the ip address that you use to access the ssh tunnel with the web browser.

    Read Next