4

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.

Wilf
  • 30,194
  • 17
  • 108
  • 164
Naveen
  • 9,365
  • 11
  • 43
  • 70
  • 1
    I have already written a tut , hopefully this will solve your doubts. This tut is for setting up wi-fi access point. You can jump to Setup internet connection settings area – Web-E Sep 25 '12 at 13:11
  • Thanks, but I'm sorry my driver doesn't show all the items in the AP list you have mentioned. My Device: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller (rev 01)

    They say that I have to enable Softmac Wireless Extentions to enable Master mode. It's too complex... Isn't there a simple way? Some code, gui or something to redirect Internet..? ...and how to find what's my ssid?

    – Naveen Sep 26 '12 at 03:43
  • 1
    See the tut was for creating wireless access point. You can create adhoc network and share it. See the Setup internet connection settings - this section does the forwarding. You can look here, a simpler step by step info. – Web-E Sep 26 '12 at 09:13

2 Answers2

3

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...!

Naveen
  • 9,365
  • 11
  • 43
  • 70
  • worked like a charm. I just exchange ppp0 to eth1 (my usb modem) and the network to my local address. thanks – Manny265 Mar 24 '16 at 11:50
0

you give in the notification area network select Create a wireless network follow the steps and ready your card happens to Access Point mode.

Note: Do not put that key shares usually happens when you put the key internet if connected verifies that the network-manager network settings you made in this mode ip shared with other pc.

ElMudo
  • 1