1

I have a raspberry pi running raspbian. I have a 3G modem connected to it, as well as ethernet. It is set up to use the modem instead of the ethernet, just in case the modem fails, I can use the ethernet. However, I cannot ssh in with the mobile card, I have to use ethernet. How can I ssh in while the mobile card is running?

1 Answer 1

1

I had exact same problem. Reason why you cannot connect to RPi during running 3G modem is default gateway.

Let me explain, when you are connected to 3G and ethernet together, packet arrives e.g. from 192.168.0.100 to your RaspberryPi ethernet interface - e.g. 192.168.0.101. Raspberry Pi responds and send packet to interface in routing table. In case of active 3G connection it sends packet to default gateway (3G dongle) which cannot route private IP address to your computer back so you won't see any response from RPi.

To solve this you can use different metric or rule based routing. Personally I use rule based routing, so I route all traffic coming from ethernet port back to ethernet so I can login to my Raspberry Pi even when I am connected to internet using 3G dongle.

See this example (you can add it to end of file /etc/rc.local and reboot your Raspberry Pi)

# Never route local traffic through 3G dongle
ip route add table 42 default via 192.168.0.1
ip rule add from 192.168.0.0/24 table 42

Just change 192.168.0.1 to your local ethernet gateway and 192.168.0.0/24 to your local network and it should works like magic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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