Creating an access point that connects to wifi

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to develop an access point that can be used to 'headlessly' connect to wifi.



AP



I am setting up the access point using hostapd conf:



interface=wlan0
ssid=AP
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0


adding to my /etc/hosts



192.168.1.1 nginx.ap.com


and to my dnsmasq:



# Never forward addresses in the non-routed address spaces.
bogus-priv
# Add other name servers here, with domain specs if they are for non-public domains.
server=/localnet/192.168.1.1
# Add local-only domains here, queries in these domains are answered from /etc/hosts or DHCP only.
local=/localnet/
# Make all host names resolve to the Raspberry Pi's IP address
address=/#/192.168.1.1
# Specify the interface that will listen for DHCP and DNS requests
interface=wlan0
# Set the domain for dnsmasq
domain=localnet
# Specify the range of IP addresses the DHCP server will lease out to devices, and the duration of the lease
dhcp-range=192.168.1.10,192.168.1.254,1h
# Specify the default route
dhcp-option=3,192.168.1.1
# Specify the DNS server address
dhcp-option=6,192.168.1.1
# Set the DHCP server to authoritative mode.
dhcp-authoritative

log-dhcp
log-queries
log-facility=/tmp/dnsmasq.log


and a LAMP server that listens for nginx.ap.com this is not really working how I imagined as I had to customise the DNS on my mac so that it would use the pis and I only get access if I type http://nginx.ap.com into the browser I was hoping I would get a pop up and all other domains would redirect to this.



networking



For my /etc/network/interfaces:



iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0



I am now trying to come up with a script that the nginx web server can run using php to close the access point and connect to the wifi using a SSID and password from a HTML form.



I have the check to see if the SSID exists in the network which works with this bash script:



if ! iwlist scan | grep ""$name"" &> /dev/null
then
echo "No such SSID - '$name'";
exit
fi


I now want to check if the password is correct and then to never use the access point again if there is a valid wifi.



So I run a simple cron like this:



if ! ping -c 2 8.8.8.8 &> /dev/null
then
service hostapd start
service dnsmasq start
else
service hostapd stop
service dnsmasq stop
fi


but this does not work properly as I will also need to control the /etc/network/interfaces and refresh the network and to do that I have to boot the user off the AP thus destroying any possible feedback.



Is there a way to check whether a config works without disconnecting the access point? And any other tips would be greatly appreciated.







share|improve this question


























    up vote
    0
    down vote

    favorite












    I am trying to develop an access point that can be used to 'headlessly' connect to wifi.



    AP



    I am setting up the access point using hostapd conf:



    interface=wlan0
    ssid=AP
    hw_mode=g
    channel=6
    auth_algs=1
    wmm_enabled=0


    adding to my /etc/hosts



    192.168.1.1 nginx.ap.com


    and to my dnsmasq:



    # Never forward addresses in the non-routed address spaces.
    bogus-priv
    # Add other name servers here, with domain specs if they are for non-public domains.
    server=/localnet/192.168.1.1
    # Add local-only domains here, queries in these domains are answered from /etc/hosts or DHCP only.
    local=/localnet/
    # Make all host names resolve to the Raspberry Pi's IP address
    address=/#/192.168.1.1
    # Specify the interface that will listen for DHCP and DNS requests
    interface=wlan0
    # Set the domain for dnsmasq
    domain=localnet
    # Specify the range of IP addresses the DHCP server will lease out to devices, and the duration of the lease
    dhcp-range=192.168.1.10,192.168.1.254,1h
    # Specify the default route
    dhcp-option=3,192.168.1.1
    # Specify the DNS server address
    dhcp-option=6,192.168.1.1
    # Set the DHCP server to authoritative mode.
    dhcp-authoritative

    log-dhcp
    log-queries
    log-facility=/tmp/dnsmasq.log


    and a LAMP server that listens for nginx.ap.com this is not really working how I imagined as I had to customise the DNS on my mac so that it would use the pis and I only get access if I type http://nginx.ap.com into the browser I was hoping I would get a pop up and all other domains would redirect to this.



    networking



    For my /etc/network/interfaces:



    iface wlan0 inet static
    address 192.168.1.1
    netmask 255.255.255.0



    I am now trying to come up with a script that the nginx web server can run using php to close the access point and connect to the wifi using a SSID and password from a HTML form.



    I have the check to see if the SSID exists in the network which works with this bash script:



    if ! iwlist scan | grep ""$name"" &> /dev/null
    then
    echo "No such SSID - '$name'";
    exit
    fi


    I now want to check if the password is correct and then to never use the access point again if there is a valid wifi.



    So I run a simple cron like this:



    if ! ping -c 2 8.8.8.8 &> /dev/null
    then
    service hostapd start
    service dnsmasq start
    else
    service hostapd stop
    service dnsmasq stop
    fi


    but this does not work properly as I will also need to control the /etc/network/interfaces and refresh the network and to do that I have to boot the user off the AP thus destroying any possible feedback.



    Is there a way to check whether a config works without disconnecting the access point? And any other tips would be greatly appreciated.







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to develop an access point that can be used to 'headlessly' connect to wifi.



      AP



      I am setting up the access point using hostapd conf:



      interface=wlan0
      ssid=AP
      hw_mode=g
      channel=6
      auth_algs=1
      wmm_enabled=0


      adding to my /etc/hosts



      192.168.1.1 nginx.ap.com


      and to my dnsmasq:



      # Never forward addresses in the non-routed address spaces.
      bogus-priv
      # Add other name servers here, with domain specs if they are for non-public domains.
      server=/localnet/192.168.1.1
      # Add local-only domains here, queries in these domains are answered from /etc/hosts or DHCP only.
      local=/localnet/
      # Make all host names resolve to the Raspberry Pi's IP address
      address=/#/192.168.1.1
      # Specify the interface that will listen for DHCP and DNS requests
      interface=wlan0
      # Set the domain for dnsmasq
      domain=localnet
      # Specify the range of IP addresses the DHCP server will lease out to devices, and the duration of the lease
      dhcp-range=192.168.1.10,192.168.1.254,1h
      # Specify the default route
      dhcp-option=3,192.168.1.1
      # Specify the DNS server address
      dhcp-option=6,192.168.1.1
      # Set the DHCP server to authoritative mode.
      dhcp-authoritative

      log-dhcp
      log-queries
      log-facility=/tmp/dnsmasq.log


      and a LAMP server that listens for nginx.ap.com this is not really working how I imagined as I had to customise the DNS on my mac so that it would use the pis and I only get access if I type http://nginx.ap.com into the browser I was hoping I would get a pop up and all other domains would redirect to this.



      networking



      For my /etc/network/interfaces:



      iface wlan0 inet static
      address 192.168.1.1
      netmask 255.255.255.0



      I am now trying to come up with a script that the nginx web server can run using php to close the access point and connect to the wifi using a SSID and password from a HTML form.



      I have the check to see if the SSID exists in the network which works with this bash script:



      if ! iwlist scan | grep ""$name"" &> /dev/null
      then
      echo "No such SSID - '$name'";
      exit
      fi


      I now want to check if the password is correct and then to never use the access point again if there is a valid wifi.



      So I run a simple cron like this:



      if ! ping -c 2 8.8.8.8 &> /dev/null
      then
      service hostapd start
      service dnsmasq start
      else
      service hostapd stop
      service dnsmasq stop
      fi


      but this does not work properly as I will also need to control the /etc/network/interfaces and refresh the network and to do that I have to boot the user off the AP thus destroying any possible feedback.



      Is there a way to check whether a config works without disconnecting the access point? And any other tips would be greatly appreciated.







      share|improve this question














      I am trying to develop an access point that can be used to 'headlessly' connect to wifi.



      AP



      I am setting up the access point using hostapd conf:



      interface=wlan0
      ssid=AP
      hw_mode=g
      channel=6
      auth_algs=1
      wmm_enabled=0


      adding to my /etc/hosts



      192.168.1.1 nginx.ap.com


      and to my dnsmasq:



      # Never forward addresses in the non-routed address spaces.
      bogus-priv
      # Add other name servers here, with domain specs if they are for non-public domains.
      server=/localnet/192.168.1.1
      # Add local-only domains here, queries in these domains are answered from /etc/hosts or DHCP only.
      local=/localnet/
      # Make all host names resolve to the Raspberry Pi's IP address
      address=/#/192.168.1.1
      # Specify the interface that will listen for DHCP and DNS requests
      interface=wlan0
      # Set the domain for dnsmasq
      domain=localnet
      # Specify the range of IP addresses the DHCP server will lease out to devices, and the duration of the lease
      dhcp-range=192.168.1.10,192.168.1.254,1h
      # Specify the default route
      dhcp-option=3,192.168.1.1
      # Specify the DNS server address
      dhcp-option=6,192.168.1.1
      # Set the DHCP server to authoritative mode.
      dhcp-authoritative

      log-dhcp
      log-queries
      log-facility=/tmp/dnsmasq.log


      and a LAMP server that listens for nginx.ap.com this is not really working how I imagined as I had to customise the DNS on my mac so that it would use the pis and I only get access if I type http://nginx.ap.com into the browser I was hoping I would get a pop up and all other domains would redirect to this.



      networking



      For my /etc/network/interfaces:



      iface wlan0 inet static
      address 192.168.1.1
      netmask 255.255.255.0



      I am now trying to come up with a script that the nginx web server can run using php to close the access point and connect to the wifi using a SSID and password from a HTML form.



      I have the check to see if the SSID exists in the network which works with this bash script:



      if ! iwlist scan | grep ""$name"" &> /dev/null
      then
      echo "No such SSID - '$name'";
      exit
      fi


      I now want to check if the password is correct and then to never use the access point again if there is a valid wifi.



      So I run a simple cron like this:



      if ! ping -c 2 8.8.8.8 &> /dev/null
      then
      service hostapd start
      service dnsmasq start
      else
      service hostapd stop
      service dnsmasq stop
      fi


      but this does not work properly as I will also need to control the /etc/network/interfaces and refresh the network and to do that I have to boot the user off the AP thus destroying any possible feedback.



      Is there a way to check whether a config works without disconnecting the access point? And any other tips would be greatly appreciated.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 3 at 12:20

























      asked Apr 2 at 23:03









      maxisme

      145111




      145111

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f435149%2fcreating-an-access-point-that-connects-to-wifi%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f435149%2fcreating-an-access-point-that-connects-to-wifi%23new-answer', 'question_page');

          );

          Post as a guest













































































          O6mojZ3K9 rZ kN 1,OMax0
          o,fE3Q Z,yOoH0heCb5ProCjUHGNCunP,2

          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          How many registers does an x86_64 CPU actually have?

          Displaying single band from multi-band raster using QGIS