Sharing wireless connection with wired computer

Yesterday I wanted to install Arch Linux on a brand new mini computer (with Quad-Core Atom!). I did that on wired connection in one place and then wanted to install additional packages at home.

Problem is: I only have wireless connection at home. So I decided I’ll share wireless connection using my laptop connected to a switch. Here is a diagram of my setup:
Network setup

The hardest part was finding manual how to do this that is on the right level of advancement. There are plenty of descriptions how to create a corporate-level network and configure that with loads of features. And they’re all far too long and quite an overkill for my purposes.

The solution I came up with comes from many sources, most notably Arch Linux wiki pages about basic routing and dnsmasq. The rest is manual pages and various other sources.

So, how to achieve what I wanted?

  1. Enable kernel routing in laptop. Hardly any manual mention that simple step. The temporary solution is to execute command “echo 1 > /proc/sys/net/ipv4/ip_forward”. Alternatively in /etc/sysctl.conf set “net.ipv4.ip_forward=1”.
  2. Install iptables and dnsmasq. Both are needed for this setup. First one will handle forwarding packets from “Laptop sara” and “Laptop router” subnets. The second is a relatively tiny DNS and DHCP server.
  3. Configure dnsmasq. In router’s subnet ip’s are from range. dnsmasq will use eth0 interface and assign ip’s from range. Here is /etc/dnsmasq.conf that will do that:
    dhcp-host=sara, # static assignment
    #log-dhcp # usefull for debugging
    log-queries # less spam than above, can be left enabled

    Of course we need to enable dnsmasq: “/etc/rc.d/dnsmasq start”.
  4. Configure iptables. Simple and fun:
    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE # note the use of 'wlan0' here
    /etc/rc.d/iptables save
    /etc/rc.d/iptables start

  5. will be used as eth0’s address. This one is simple: “ifconfig eth0 up && ifconfig eth0”. I also had to turn of wicd connection manager daemon, since it used to disconnect me from wired connection from time to time for no real reason: “/etc/rc.d/wicd stop”.
  6. All that is left is making sara ask for assignment: “sudo dhcpcd” and done. We are up and running!

~ by Tener on 07/01/2010.

One Response to “Sharing wireless connection with wired computer”

  1. After trying a lot of things with NetworkManager, this was VERY helpful 🙂

    Thanks for sharing.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: