Debian hostapd internet ip routing

0

I am now working on pine64 with debian8 installed. I am trying to set up a hotspot with hostapd and i want to share the network of wlan0 with wlan2 which is the hotspot. Now i have set up a hotspot(wlan2) and the client is able to connect with it. I am not going to use DHCP and i want to set all the ip manually. Now the situation is i can connect my ipod to the pine64 and ping it but cannot connect to the internet.

I set up the hostapd first.

interface=wlan2
driver=nl80211
ssid=test
hw_mode=g
macaddr_acl=0
auth_alg=0

and also set up the wlan2

iface wlan2 inet manual
hostapd /etc/hostapd/hostapd.conf
address 192.168.2.1
netmask 255.255.255.0
broadcast 192.168.2.255

I have then set up the kernel IP routing table.

Destination Gateway      Genmask        Flags Metric Ref Use Iface
0.0.0.0     192.168.1.1  0.0.0.0        UG    1024   0     0 wlan0
192.168.1.0 0.0.0.0      255.255.255.0  U     0      0     0 wlan0
192.168.2.0 0.0.0.0      255.255.255.0  U     0      0     0 wlan2

With the above set up the pine64 is able to ping my connected device. Then i set up the ipv4 ip forward table.

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan2 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan2 -o wlan0 -j ACCEPT    

My pine64 connect to the router with ip address 192.168.1.109, then i set up my ipod to connect with the pine64 with the below setting.

IP Address 192.168.2.20
Subnet Mask 255.255.255.0
Router 192.168.1.109
DNS 192.168.1.109

But i find that i cannot to the internet with my Ipod, sorry for the poor english. Hope someone can help me. Thanks a lot.

leochan2k

Posted 2016-06-06T03:05:42.817

Reputation:

Answers

0

Try removing the interface names (-i wlan0 -o wlan2) from the first FORWARD chain rule. Also, the "state" extension has been superseded by "conntrack".

This should work:

sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

Alex O

Posted 2016-06-06T03:05:42.817

Reputation: 101