Thursday 31 December 2015

Sharing a Laptops WiFi through Ethernet

Here are 3 different ways you can share your laptops WiFi through ethernet to another computer so that that computer can access the internet.
(When your set-up is like the following diagram.)

Desktop --- Ethernet --- Laptop --- WiFi --- Router

A desktop computer connected from its ethernet port to the laptops ethernet port using a cable and that laptop connected to a wireless router via WiFi.
In order of easiest to complicated.

1) "Shared to Other Computers" 

This way is very quick and easy to set up. Unfortunately it doesn't port forward for servers and such. Internet and IM programs work fine, but if you want to host a game server or web-server you'll have to go to option number 2 (or 3).

----Laptop:
  • Have your laptops wireless card connect to the router in its usual way.
  • Add a new ethernet connection (in your network connections settings), go into the "IPv4 Settings" and change the Method to "Shared to other computers" 
    "Shared to other computers"
----Desktop:
  • Add a new ethernet connection (the same way as on your laptop), go into the "IPv4 Settings" and change the Method to "Automatic (DHCP)"

2) IP tables

This way requires manually entering IP addresses. It allows you to host servers on the desktop computer by port forwarding through the laptop. Unfortunately it only allows one computer to be connected to the laptop which will be fine for most people, however if you want multiple computers connected to a router connected to the laptop then you will need to go for option 1, in addition if any of those computers need to host a server you will need to go for option 3.

----Laptop:
  • Have your laptops wireless card connect to the router in its usual way.
  • Add a new ethernet connection. In "IPv4 Settings" change the Method to "Manual" and fill out the following:
    • Address: 10.0.10.1
    • Netmask: 255.255.255.0
  • Make sure the gateway is left blank (otherwise the ethernet will become your default net connection and you will get not internet from your wifi).
  • Next open terminal and enter the following two lines:
iptables -t nat -A POSTROUTING -o wlan0 -s 10.0.10.0/24 -j MASQUERADE
iptables -t nat -A PREROUTING -i wlan0 -j DNAT --to-destination 10.0.10.2
----Desktop:
  • Add a new ethernet connection. In "IPv4 Settings" change the Method to "Manual" and fill out the following:
    • Address: 10.0.10.2
    • Netmask: 255.255.255.0
    • Gateway: 10.0.10.1
    • DNS Servers: 8.8.8.8
You can set up the network connections to connect by default however you will have to put in the iptables on every boot (unless you make a script to do it automatically).
The Addresses used are nothing special and you can put the address in which ever values you want (so long as the first 3 numbers are the same) 10.0.23.*, 192.168.0.*, etc.

3) Routing Software "Quagga"

I'm still yet to figure this one out, but you're welcome to give it a try.
Quagga - www.nongnu.org/quagga/
"Quagga is a routing software suite, providing implementations of OSPFv2, OSPFv3, RIP v1 and v2, RIPng and BGP-4 for Unix platforms, particularly FreeBSD, Linux, Solaris and NetBSD."

No comments:

Post a Comment