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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Simple and platform agnostic:
- Ensure that the two networks to be bridged have different subnet addresses.
- 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.
Method 2
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
- 192.168.0.1 is the IP address we assign to PC1
- 192.168.0.2 is the IP address we assign to PC2
- 10.0.0.2 is the IP address for the nameserver used by PC1 (
cat /etc/resolve.confon PC1 )
ON PC1:
eth0 is the network interface that connects to PC2
# configure eth0 ifconfig eth0 192.168.0.1 netmask 255.255.255.0 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
ON PC2:
eth0 is the interface that connects to PC1
# enable eth0 ifconfig eth0 192.168.0.2 netmask 255.255.255.0 ifconfig eth0 up # route through other pc route add default gw 192.168.0.1 # specify nameserver echo "nameserver 10.0.0.2" >> /etc/resolve.conf
See Internet Share for reference.
Method 3
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.
Method 4
Ok, I don’t think I really have the answer here but here it goes:
- Connect your laptop to the WLAN,
- Connect your Desktop to your Laptop (make sure to configure the IP’s properly, or have a DHCP server on your laptop),
- 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0