4

I got a question. How to make Pi to be an AP with 2 wifi adapters, one wifi adapter is used to connect to the router, and another one is used to be an AP ? How to do this ?

By the way, I have realized that make an AP with eth0 and wlan0, using "hostapd" and "isc-dhcpd-server".

There is another thing, when I make the AP, I didn't use the bridge that bridge eth0 to wlan0 or bridge wlan0 to wlan1, I am using the isc-dhcp-server.

As I said, I have realized AP with eth0 and wlan0, the isc-dhcp and hostapd just need to appoint which network card will be used as AP, so I am wondering the problem is occurred when configuring the iptables, here is how I configured the iptables when I using eth0 and wlan0:

$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
syb0rg
  • 8,178
  • 4
  • 38
  • 51
user11257
  • 41
  • 1
  • 1
  • 3

3 Answers3

4

You have to initalize your hostapd interface on e.g. wlan0. After that you can bring up your wlan1 and connect it to your router. Now you can bridge wlan0 and wlan1 like this:

apt-get install bridge-utils

brctl addbr bridge0
brctl addif bridge0 wlan0
brctl addif bridge0 wlan1
ifconfig bridge0 up

You can assign an ip to that bridge with:

dhclient bridge0

Now all packets from/to wlan0 to/from wlan1 will be redirected.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
Alex Tape
  • 654
  • 1
  • 5
  • 12
1

I have done the same thing with my rpi-2 using hotapd and ics-dhcpd-server and in addition installed openvpn and set it up as a vpn router. All you need to do is

sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

once the vpn server is up and running.

So now rather than using eth0 I just plug in another wifi dongle and I get a mobile vpn router I can carry around ....

wlan1 connects to my isp router and wlan0 is vpn The problem is having two rf modules in very close proximity induces cross-talk ....

Bex
  • 2,929
  • 3
  • 26
  • 34
user28463
  • 11
  • 1
0

This script logs the Pi into a wireless network (e.g. 802.1x) and then configures an access point on a second wifi adapter. https://github.com/DrRowland/pifi2wifi I could not get the above bridge method to work as specified in the question, and so provide this as a working solution.