a stupid way of internet sharing between two laptops

April 6th, 2008 mysurface Posted in Admin, ifconfig, ssh | Hits: 81496 | 8 Comments »

I always want to find an easy way to do an internet sharing between my two laptops. Well I figure out a way, which is really stupid! but well, for some extend, it works. I know there should be a proper ways to do that, but with the limited knowledge of networking, this is only what I can come out for the moment.

If you are a super linux admin user and reading this, try not to think in the perspective of admins, but try to put yourself as a layman, as I doesn’t know much about hard core network stuff, but I know ifconfig and ssh, which is some how efficient to make a “fake” internet sharing works.

Okay! lets look at the scenario I have. I have a new laptop (L1) that have wireless capabilities as well as wired installed with fedora 8. And another old laptop (L2) which only have LAN port installed with kubuntu. Obviously I want to share my internet connection from L1 to L2, well is a bit easy for me, because both of them are running linux.

I use wlassistant to connect myself to wireless LAN because fedora 8 Network Manager is so “intelligently” switch to wired when i plug in my LAN cable. After L1 is hook up to the internet wirelessly, i setup my eth0 with root privilege.

ifconfig eth0 netmask up

Okay L1, is done, lets look at L2, same way i setup my eth0 at L2.

ifconfig eth0 netmask up

Connect both LAN ports with LAN cable, and then do ping from L2!


Okay! Now let me reveal the stupid but working way using ssh. I do this at L2.

ssh -Y mysurface@ konqueror

Haha! konqueror start up and now you can surf the net from L2!

Eh! wait what is -Y option of ssh? and Why it works?
If you read up the ssh manpage, you will get this line

-Y Enables trusted X11 forwarding.

Yeah, I am loading L1’s browser and run it at L2, you can try to save a files from the internet. It will save it in L1 instead of L2, therefore this is not a real Internet sharing!

Well, I still figuring how to do an internet sharing across the LAN cable.

Do a bridging at L1 between wireless and wired interface? Then do a dynamic tunneling from L2? I tried and it doesn’t seems to be working.

Play some trick in iptables to do ip forwarding? emm may be I should try this out.

Dear Admin, do you have any suggestion?

8 Responses to “a stupid way of internet sharing between two laptops”

  1. enable ip forwarding (L1)
    # echo 1 > /proc/sys/net/ipv4/ip_forward

    iptables (L1)
    #iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    #iptables -A FORWARD -i eth1 -j ACCEPT

    add route (L2)
    #route add -net 0/0 gw

    that should enable simple routing on L1 for you ..

  2. Here’s my way of sharing an internet connection

  3. Thanks LiteSpeed and Binny VA, will try it over the weekend.

  4. u got it halfway already, the next thing, at L1 run system-config-firewall and configure masquerade (just tick all eth+).

    then, at L2, set the gateway to L1

    another trick is to use SSH’s -D[Port] (Dynamic port forward) as a Socks5 proxy

  5. PSP Internet Says:

    Great post. Thanks for the info, very useful and interesting stuff

  6. Ryan Gooler Says:

    FYI: Unless you have a modern laptop (with an auto-sensing NIC), using this trick will require a crossover cable, not a standard lan cable.

    And, yes, this is coming from a network guy.

  7. Quite nice post. I discovered your site as well as planned to express that We have actually relished looking your current web site posts. Whatever the case I shall be registering to your own rss feed we we do hope you produce yet again quickly!

  8. A interesting blog post right there mate . Thanks for posting !

Leave a Reply