Sharing Internet connection via ssh

2

1

I have desktop and two laptops with Ubuntu. Normally, internet is shared via router with one port for PPP to provider and four for computers. But router broke and now it works only as switch. So, if I plug all my computers and providers wire into it, I have local network, but only one computer at time can access Internet via ppp. So, I login to Internet with my desktop and use ssh to access it from my laptops. That allows me to run applications and surf Internet on my laptops, but no full access to Internet.

So, the question is - is there a way to share Internet via ssh, so the laptops will have it in same way as connecting to it directly or via router (of course, I will get new router, but the question has theoretical interest and applications like tunneling traffic via safe machine).

user81420

Posted 2011-05-15T21:47:03.137

Reputation: 245

I'm quite interested in the answer to this: it sounds like it might be a networking nightmare, but it's an intriguing idea. – Lukasa – 2011-05-15T21:57:11.737

Answers

3

Does it have to be over SSH? It's much simpler to share the connection using standard routing. Since this is all inside the same LAN, you don't lose any security.

If you do need an encrypted connection, consider OpenVPN instead. Run the VPN server on your desktop and connect from laptops; use the same instructions above for connection sharing.

The SSH protocol is not suited for low-level tunneling. However, OpenSSH does have very basic VPN support with the -w option.

user1686

Posted 2011-05-15T21:47:03.137

Reputation: 283 655

Well, I'll have a look at -w flag. Maybe it will help. – user81420 – 2011-05-15T22:32:07.497

And about sharing connections - all solutions which i've seen involved second network card or router. As I told, i will buy a new router, but i'm curious - if I can surf internet on all computers with one net card per computer and a switch - why can't I get full intenet access with one card? I don't see why it's not technically possible. – user81420 – 2011-05-15T22:36:25.170

@user: It is possible. But a more detailed description of your setup would be useful. How exactly is your desktop connecting? Is it using PPPoE? What software? (The two NICs do not have to be both physical -- virtual ones, such as tun0 or ppp0, work the same way as eth0.) – user1686 – 2011-05-16T04:07:44.117

+1 for openVPN, this is the kind of thing that VPNs are for, not SSH. – MaQleod – 2011-05-16T04:55:53.907

@grawity: I've connected all computers and providers wire to four router ports. Then I ran dhclient on all computers and set ips via ifconfig, so I now have desktop eth0 as 192.168.0.100 and laptops eth0's as 192.168.0.101 and 192.168.0.102. After that I run pppoeconf on computer I select (for example, desktop), enter my providers login and password. Now Internet is working only on desktop. Then I ssh -X from laptops to desktop, run browsers and browse web.

So, desktop has eth0 and ppp0 and laptops ony eth0's. – user81420 – 2011-05-16T10:19:07.510

@user: You should be able to follow the standard connection sharing instructions on your desktop computer. Just replace eth0/eth1 with ppp0/eth0. And don't mix dhclient with manual IP configuration... – user1686 – 2011-05-16T15:02:20.023

@user: Quick summary: echo 1 > /proc/sys/net/ipv4/conf/all/forwarding && iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE – user1686 – 2011-05-16T15:06:10.537

@user: ... on laptop, ip route add default via 192.168.0.100; – user1686 – 2011-05-16T15:14:05.273