What's a simplistic recipe to connect my PC to my WLAN through my laptop?

I have one wireless network, one desktop that (for practical reasons) has no connection to the WLAN, and one laptop with wireless and an ethernet port.

I would like to run a cable from my desktop to my laptop, connect my laptop to my WLAN and forward the network to my desktop.

Is there a solution?

  • What unix variant does your laptop run? The commands will be different on different variants. If it's Linux, specify your distribution: there may be a distribution-specific way that's a lot simpler than the simplest distribution-agnostic way. – Gilles 'SO- stop being evil' Sep 6 '10 at 21:52
  • I am running archlinux, but I think more people could benefit from a "distribution-agnostic" answer... – Stefan Sep 6 '10 at 22:09

Simple and platform agnostic:

  1. Ensure that the two networks to be bridged have different subnet addresses.
  2. Enable standard Linux IP forwarding in /etc/sysctl.conf.

For different subnets, assuming you are using the allocated private class C space, 192.168.1.* and 192.168.2.* are different subnets.

|improve this answer|||||

Asuming that:

  • PC1 has a working internet connection which we want to share with PC2.
  • PC1 is connected to PC2 with a cross-over cable or a switch
  • is the IP address we assign to PC1
  • is the IP address we assign to PC2
  • is the IP address for the nameserver used by PC1 ( cat /etc/resolve.conf on PC1 )


eth0 is the network interface that connects to PC2

# configure eth0
ifconfig eth0 netmask
ifconfig eth0 up

# enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# forward with iptables
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/etc/rc.d/iptables save
/etc/rc.d/iptables start


eth0 is the interface that connects to PC1

# enable eth0
ifconfig eth0 netmask
ifconfig eth0 up

# route through other pc
route add default gw

# specify nameserver
echo "nameserver" >> /etc/resolve.conf

See Internet Share for reference.

|improve this answer|||||
  • 1
    on PC2, shouldn't the gateway be set to and there is a confusion in the 1st part (both addresses are assigned to PC1) – gurney alex Aug 15 '11 at 8:28
  • bash: /etc/rc.d/iptables: No such file or directory – tsbertalan Oct 20 '17 at 20:24

You can also connect the laptop to the WLAN, the desktop to Laptop and only bridge the connections on the laptop so you don't need to run anything on the laptop (DHCP/NAT). The Desktop will get its config from the WLAN dhcp.

|improve this answer|||||

Ok, I don't think I really have the answer here but here it goes:

  1. Connect your laptop to the WLAN,
  2. Connect your Desktop to your Laptop (make sure to configure the IP's properly, or have a DHCP server on your laptop),
  3. Use firestarter (should be available on your package manager) to create a bridge between the two connections.

That's as far as I could get by researching the subject; hope this info serves as a good starting point.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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