6

On my Debian Linux device, I have a USB-modem that is connected to the Internet. Its interface name is ppp0.

I also have a USB-wireless adapter, where I am hosting a Access Point. Its interface name is wlan0.

How to I route traffic between these interfaces, so that if my phone is connected to this AP, that I can access the Internet via ppp0?

EDIT 1: I tried setting up some routing, but does not seem to work. Here are the details:

# iptables --list-rules
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o ppp0 -j ACCEPT

# iptables --list-rules -t nat
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -o ppp0 -j MASQUERADE

EDIT 2 SOLVED: I was able to solve my problem. I was using the same subnet for wlan0 and ppp0. When using different subnets for wlan0 and ppp0, everything worked fine. I also found this article useful: http://elinux.org/RPI-Wireless-Hotspot

1 Answer 1

4

You can refer to this wiki that explain a very simple and complete way of acheving what you want with iptables, This explain how to Nat your wifi interface behind you ppo interface.

Edit 1: You can also make your two interface working as a bridge aka switch but it would probably be a bit more tricky, some info about that here

2
  • 2
    Thank you. I used some iptables rules that where supposed to work, but they did not. It turned out later that my problem was not the iptables rules, but that I was using the same subnet for both wlan0 and ppp0. Using different subnets solved the problem. Commented Jan 9, 2014 at 9:18
  • I'm glad it does work.
    – Kiwy
    Commented Jan 9, 2014 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .