Sharing a laptop's wireless Internet connection with other computers connected to its Ethernet port is a great skill to know. It can be good for a number of reasons; Your computer may not have proper hardware to have a standard setup, or you may have an awkward network topology where sharing your wireless Internet via Ethernet would just be a better option.
Windows make it pretty easy for you. Just right-click the network profile and hit "share".
If you have Linux or Mac, it's a bit more difficult. These systems use IPtables to configure how they control ports, masquerading, port forwarding, and all things of that nature. This Null Byte is for you home users who need to share your wireless Internet to gaming consoles like the Xbox 360, or to network admins who aren't very familiar with Linux servers.
Step 1 Download IPtables
We are going to start by downloading the iptables package. I'm using Arch Linux. Ubuntu users will need to use apt-get install instead of pacman -S. Mac users already have it pre-installed, so you can skip this step. Things in bold are the terminal commands you should enter.
sudo pacman -S iptables
Step 2 Configure IPtables
Now we need to set our IPtables up to forward the Ethernet traffic to your wireless interface.
Bring your Ethernet interface up:
sudo ifconfig eth0 up
Now, assign a static IP to the Ethernet interface:
sudo ifconfig eth0 192.168.2.1
Now, enable IP forwarding from your Ethernet interface. This will allow it to be shared.
sudo echo "1" > /proc/sys/net/ipv4/ip_forward
This last command will forward everything within the 192.168.2.* IP range.
sudo iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE
When that's all set, I reccommend you throw all of the commands in a script at the end of your /etc/rc.conf file. Here is what mine looks like:
(Note: You don't have to use the 192.168.2.* range… I just use it for these tutorials to avoid device conflicts. Change the 2 to a 1 if you want to keep things normal.)
Step 3 Configure the Ethernet Device
I'm going to be using an Xbox 360 as an example for my Internet sharing. The same rules will apply across any device.
Here are the settings I used:
- Static IP: 192.168.2.2
- Gateway: 192.168.2.1
- DNS: 192.168.2.1
If your device doesn't receive Internet, try rebooting with the Ethernet cable left in.
That's all you need to remember when configuring devices to use your laptop's wireless Interface via Ethernet. That's also how to get a free wireless adapter on older Xbox 360s! Null Byte kills two birds with one stone!
Want to start making money as a white hat hacker? Jump start your White-Hat Hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from Ethical Hacking Professionals.