Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
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 3: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 9:13

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer

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.

share|improve this answer
    
Sorry it doesn't work, because I'm using a usb modem.. –  Naveen Sep 26 '12 at 3:22
    
It doesn't matter if my ip gets shared. –  Naveen Sep 26 '12 at 3:45
1  
no matter if you use usb modem. the ip which is the other must share the outgoing exit either lan or wlan –  ElMudo Oct 1 '12 at 2:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.