Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a linux PC (Debian Squeeze) which is located into a room in another town (I cannot physically access to this PC from where I am)

This PC is linked to internet using an internet box. I can connect to this PC using ssh through port 22 (actually I have a NAT from remote box port XXXX to PC's port 22).

One of my collegue connects a 3G key. I then use sakis script to connect this PC to 3G network, and then my ssh connection is hanged (Broken pipe). My collegue can still access to the PC from his local network using ssh; I can't.

What are the reasons why 3G connection stops the external ssh connection ? How can I solve this issue (keeping my ssh connection opened while 3G connection is made) ?

Edit: additional information

I connect using the NAT, before 3G script is launched

IP does not change for eth0 (the interface I use to connect)

A new interface is added after 3G connection :ppp0 Link encap:Point-to-Point Protocol

ip route (before 3G connection)

172.16.210.0/24 dev br0  proto kernel  scope link  src 172.16.210.254 
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.50 
default via 192.168.0.254 dev eth0 

ip route (after 3G connection)

10.64.64.64 dev ppp0  proto kernel  scope link  src 10.99.122.183 
172.16.210.0/24 dev br0  proto kernel  scope link  src 172.16.210.254 
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.50 
default via 10.64.64.64 dev ppp0 
share|improve this question
    
To clarify: a) your colleague is connecting via the local network whereas you're trying to connect via the NAT? b) Did the IP address on eth0 or the routing table ("ip route" output) change? c) Not familiar with the script, did it add another interface (like a virtual one) to the system? –  Joel Davis Apr 9 '13 at 16:02
    
$a) I try to connect using the NAT, before 3G script is launched | b) the ip did not change for eth0 (the interface I use) c) yes, it added an interface: ppp0 Link encap:Point-to-Point Protocol –  lauhub Apr 9 '13 at 18:28
    
Did the output of the routing table change when it added the ppp0 interface? It may be routing the response out an interface we're not expecting. –  Joel Davis Apr 9 '13 at 18:37
    
You can check the routing table with the "ip route" command BTW –  Joel Davis Apr 9 '13 at 18:39
    
I added this information in the edited question –  lauhub Apr 10 '13 at 10:46

1 Answer 1

After running that script, your default route points to another interface. Your ssh connection's data get sent there, but get thrown away because they have the wrong address, are NATted by the 3G network to some unrelated address, and/or whatever.

Solution: Add an explicit route. The variable $SSH_CLIENT tells you where the connection is coming from.

# set $SSH_CLIENT
# ip route replace $1 via 192.168.0.254 dev eth0

should solve your problem.

share|improve this answer
    
Sorry, I'm a little bit confused with your script. Should I add this to the 3G connection script ? After or before 3G connection command ? Or elsewhere ? It is $1 I should use but where is it set ? –  lauhub Apr 17 '13 at 22:03
    
You can add it to the beginning of your 3G connection script, sure. The $1 is set by the set $SSH_CLIENT line, see the shell's manual page. –  Matthias Urlichs Apr 18 '13 at 7:12
    
NB: I fixed the route command, should have been ip route. –  Matthias Urlichs Apr 18 '13 at 7:15

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.