1

So the first part of this was to setup the wifi adapter as an wireless AP which I managed to do.

The wireless adapter address is 10.0.0.1

The connected device is given an ip address using hostapd between 10.0.0.2 - 10.0.0.100. This works fine.

I have tested this setup with a local webserver (lighttpd) and using the rule in dnsmasq "address=/#/10.0.0.1" I was able to redirect all wifi traffic to my local webserver.

I now have setup my webserver on a dedicated PC (connected to a machine which will be controlled via webserver).

I want to redirect all wifi traffic to the ip address of the dedicated PC. When I plug the PC into the eth0 port of the raspi it gains an ip address from the raspi. Which seems like its working well.

Problem is that I can not ping the PC's ip address from my wifi device. I have tried following a few tutorials on how to bridge the two adapters, but this does not seem to be the right solution.

What is the next step, or what is needed to allow me to route all wifi traffic to the ip address of my dedicated PC on the eth0 interface?

  • the PC is directly connected to the eth0? What IP range you are using for eth0? – Joe Platano Mar 17 '17 at 3:58
1

When I was doing a project like this I used iptables. Remove the address=/#/10.0.0.1 from dnsmasq. Remove any bridges you setup and try this:

  • Enable IP forwarding: sudo sysctl -w net.ipv4.ip_forward=1
  • sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  • sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.1.254
  • sudo iptables -t nat -I PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.1.254

Change the IP 192.168.1.254 to the ip address of your webserver on the dedicated PC. You may not want to re-route https to your server (the third line above) unless you have a certificate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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