Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to perform iPerf test between my Android device (rooted Samsung Galaxy S4 LTE) and my external server.

Let's say:

Site A - Rooted Android device with mobile internet access (behind the Mobile Network Operator's NAT) Site B - External server (debian70_64) with public IP address.

Iperf test:

Site A:

iperf -c SERVER_IP -p 5001 -i 1 -r
------------------------------------------------------------
Cclient connecting to SERVER_IP, TCP port 5001
TCP window size: 19.9 KByte (default)
------------------------------------------------------------
[ 5] local MOBILE_IP port 59458 connected with SERVICE_IP port 5001
[ ID] Interval  Transfer    Bandwidth
samples
Waiting for server threads to complete. Interrupt again to force quit

Site B:

iperf -s -p 5001
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[  4] local SERVER_IP port 5001 connected with MOBILE_IP port 5357
output
connected failed: Connection refused

It has to be failure because my device is behind the NAT so I can't make reverse (-r) test. I've decided to pipe iPerf via reverse SSH Tunnel. Does it make any sense?

SCHEME ON IMGUR - http://i.imgur.com/gyHD6OU.png

First step: Reverse SSH Tunnel

On Site B I modified

/etc/ssh/sshd_config

MaxStartups 10:30:60
UsePAM yes
AllowTCPForwarding yes
PermitTunnel yes
GatewayPorts yes

/etc/hosts.allow

sshd: ALL

And I restarted sshd

service ssh restart

[ ok ] Restarting OpenBSD Secure Shell server: sshd.

which ssh

/usr/bin/ssh

which sshd

/usr/sbin/sshd

On Site A (behind the NAT) I started SSH session. I use 'Better Terminal Emulator Pro' from Google Play

ssh -g -R 0.0.0.0:5555:localhost:22 user@SERVER_IP

It worked fine

Netstat -pant

Site A:

root@jflte:/ # netstat -pant
netstat -pant
Proto Recv-Q Send-Q Local Address          Foreign Address        State
 tcp       0      0 MOBILE_IP:51369   SERVER_IP:22      ESTABLISHED

Site B:

netstat -pant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1925/rpcbind    
tcp        0      0 0.0.0.0:5555            0.0.0.0:*               LISTEN      2792/1          
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      2291/vsftpd     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2629/sshd       
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2656/exim4      
tcp        0      0 0.0.0.0:41609           0.0.0.0:*               LISTEN      1957/rpc.statd  
tcp        0     44 SERVER_IP:22       MOBILE_IP:38131       ESTABLISHED 2790/sshd: USER [p
tcp6       0      0 :::111                  :::*                    LISTEN      1925/rpcbind    
tcp6       0      0 :::5555                 :::*                    LISTEN      2792/1          
tcp6       0      0 :::22                   :::*                    LISTEN      2629/sshd       
tcp6       0      0 ::1:25                  :::*                    LISTEN      2656/exim4      
tcp6       0      0 :::45755                :::*                    LISTEN      1957/rpc.statd  

And reverse SSH Tunnel:

ssh -p 5555 SERVER_IP@localhost -v

OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug: Connecting to localhost [::1] port 5555.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-sert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host

I've tried to play with iptables but it's really confusing. Do you have any idea how to establish reverse SSH Tunnel to Android device? Is it possible in this case?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.