-   Linux - Newbie (
-   -   Sharing network connection from one linux machine to another via ethernet (

platterofhotfish 04-23-2017 11:15 AM

Sharing network connection from one linux machine to another via ethernet
Hello all,

I have two linux machines, Both are fairly old computers so I am running lighter distros. I have a laptop running sparky linux and a tower running lubuntu. The laptop has a wireless network card and it works just fine but the tower's network card is ethernet only.

Is it possible to connect the two computers with an Ethernet cable and share the internet connection from the laptop to the desktop?

Eventually I will be buying some new equipment so that this would not be necessary but in the meantime since I have the cable I wanted to know how I would do it.

As far as my level of technical acumen, I work for an ISP in data repair so I am very familiar with networking and TCP/IP. I have used linux many, many times but I never get really deep into it so I would still say I am a beginner to it so please keep the answer simple for me. Thanks!

fatmac 04-23-2017 01:11 PM


Originally Posted by platterofhotfish (Post 5701092)
.... so please keep the answer simple for me. Thanks!

Yes. :)

platterofhotfish 04-23-2017 04:54 PM

Haha, My fault. Maybe a little more complex than that.
Since it is possible, how would one go about doing this?

yancek 04-23-2017 05:40 PM

What happens when you connect an ethernet cable to your laptop and the other end to the Desktop?
What have you tried?
How do you connect to the internet? Wireless modem, router, etc.. Most wireless modems and routers have ethernet ports.

michaelk 04-24-2017 05:23 AM

You can use NetworkManager in each computer to configure the ethernet adapter with a static IP address. Make sure it is not the same as your LAN like and netmask The gateway of the desktop should be the static IP address of the laptop. Add the DNS servers from your ISP to the desktop settings.

On the laptop you need to enable forwarding.
sysctl -w net.ipv4.ip_forward=1

Not sure what firewall is running in sparky or how it is configured so the exact rules might need to be modified but you do need:
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

Change wlan0 to match your actual wireless adapter device

jefro 04-25-2017 03:35 PM

Extra information.

DVOM 04-26-2017 03:19 PM

When I used to do this, I just opened the "edit connection" on the wireless machine, then on the IPv4 tab under "Method" check "shared to other computers". Then run your ethernet cable and you're good to go.

Rickkkk 04-26-2017 03:52 PM

I would have the same question as Yancek at this point: how is your laptop even connecting to the internet ? I would assume as well that it's via some router or modem and that a simpler solution would be to connect the tower directly to the router instead of using the laptop as a gateway.

If for some reason this is not possible, then michaelk has provided some pretty detailed info in post #5 on how to set up using the laptop as a gateway.


All times are GMT -5. The time now is 02:14 PM.