Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 11060  / 2 Years ago, sat, august 20, 2022, 9:21:27

Can somebody please make a short & sweet tutorial telling how to forward an Internet connection to different network interfaces in Ubuntu...?

This is the idea:



I'm using a 3G usb modem to get Internet on my laptop ,which is:




ppp0 IP=10.225.174.70




My Wifi device is:




wlan0 MAC=78:e4:00:d4:3d:85




These devices are determined from ifconfig command.



I want to share ppp0's internet connection with wlan0 device, so I can connect any other device to wlan0 and browse internet from that device.



Making a Hotspot using Network settings GUI doesn't do the trick because the other device won't receive Internet, it just connects to wlan0.



I heard iptables can do this, but I'm totally confused by the alien commands seen online. I'm no expert in networking. Please compose a clear & simple answer using the above devices. This is a huge annoying problem for iPhone & tablet users came to Ubuntu from Windows.


More From » networking

 Answers
5

This is how I worked it out...



  1. Create a new wireless network (aka hotspot) using the network manager.

  2. Enable IP forwarding by executing the command below:



echo 1| sudo tee /proc/sys/net/ipv4/ip_forward




  1. Identify the device which connects your computer to Internet, by using ifconfig command. (My one is ppp0, because it has an IP address.)

  2. Finally tell iptables to forward ppp0's internet traffic to everywhere!



sudo iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o ppp0 -j MASQUERADE



Disconnect & reconnect the Wifi connection(Hotpsot) you made earlier.

Internet should be flowing to the wireless network now!

If you did it correctly, the output of sudo iptables -L should be similar to this:



Chain FORWARD (policy ACCEPT)

target.....prot opt.....source....................destination

ACCEPT.....all ---........ anywhere.............10.42.43.0/24.........state RELATED,ESTABLISHED

ACCEPT.....all ---........ 10.42.43.0/24......anywhere



An external guide is available here.


Thanks to web-E...!


[#35333] Monday, August 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breadoules

Total Points: 212
Total Questions: 118
Total Answers: 120

Location: Dominica
Member since Mon, Jun 22, 2020
4 Years ago
;