How to create a wifi hotspot in Windows 7 + redirection to a local webpage?

5,181
  1. Get MaraDNS

MaraDNS is a free, lightweight and relatively easy-to-configure DNS server for Windows and Linux. Download it from here and unzip it to some folder.

  1. Configure MaraDNS

Open “secret.txt” and change the value to something else (random characters).

The MaraDNS configuration is in the “mararc” file in the same directory. DNS servers have two sets of functionality. They can function as a “Authoritative name server” or a “Recursive/caching name server”.

Authoritative name servers specify IP addresses for domain names. Recursive name servers store information from authoritative name servers and pass on queries in a recursive manner.

We will be configuring both authoritative and recursive functionality in MaraDNS.

2.1 Authoritative configuration

We will configure the server to provide authoritative names of the LAN domain names. Pick any domain, I chose “local.com” (note though that you will not be able to access the actual “local.com” website if you pick an existing domain name).

Add configuration lines to “mararc” like these:

csv2 = {}
csv2["local.com."] = "db.lan.txt"

Where local.com is the domain name you picked, and db.lan.txt is the name of the second configuration file which we will be creating next (change it if you want to name the second configuration file).

Create a new file named “db.lan.txt” in the same directory as MaraDNS.

For each of the computers you want to resolve to a name, add a line to “db.lan.txt”. For example, for two machines, one “dev.local.com” and the other “blog.local.com”, add the following lines:

dev.%       192.168.1.4 ~
blog.%        192.168.1.6 ~

Done!

2.2 Recursive configuration

We will setup MaraDNS to ask your default name servers for all other domains so that you can resolve all other domain names to their correct IP addresses.

Find out your ISP’s DNS server addresses. These are likely to be listed either on the Router status page, or by checking the details on your network adapter.

Now add your ISP’s DNS servers as upstream servers in “mararc”:

upstream_servers = {}
upstream_servers["."] = "xxx.xxx.xxx.xxx, yyy.yyy.yyy.yyy"

Where xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy are your ISP’s DNS servers.

Done!

  1. Run MaraDNS and test it using askmara.exe

Double-click “runmara.bat” , and leave the server running.

Open a command prompt, navigate to the MaraDNS directory and try running:

askmara.exe Agoogle.com.

and

askmara.exe Ablog.local.com.

You should get replies like this:

# Querying the server with the IP 127.0.0.1
# Question: Agoogle.com.
google.com. +300 a 74.125.67.100
google.com. +300 a 74.125.53.100
google.com. +300 a 74.125.45.100
# NS replies:
# AR replies:

and:

# Querying the server with the IP 127.0.0.1
# Question: Ablog.local.com.
blog.local.com. +86400 a 192.168.1.6
# NS replies:
#local.com. +86400 ns synth-ip-7f000001.local.com.
# AR replies:
#synth-ip-7f000001.local.com. +86400 a 127.0.0.1

If you get problems with the first query, you messed up the recursive DNS settings (are your ISP DNS server addresses correct?), and if you get an error with the second query, you messed up the authoritative settings.

  1. Change MaraDNS to reply to queries from your LAN

Shutdown the MaraDNS window, and change the first two lines of “mararc” to something like:

ipv4_bind_addresses = "192.168.1.2
recursive_acl = "192.168.1.0/24"

Where 192.168.1.2 is the IP address of the computer on which the server will be running and the “192.168.1″ part of recursive_acl is the same as on your network (might be 192.168.0.0/24).

Start MaraDNS again, and leave it running.

  1. Setup your router to hand out your new DNS server

Open your router’s web interface and find the DHCP server settings. There should be an option to set up a DNS server. Write the IP address of the computer on which the DNS server will be running.

For each of your computers, disconnect the network (e.g. by disabling and enabling it in Windows, or by using “ifconfig eth0 down”/”ifconfig eth0 up” on Linux).

That’s it, you should now be able to refer to your LAN computers by their domain names.

Source

Share:
5,181

Related videos on Youtube

Federico
Author by

Federico

Updated on September 18, 2022

Comments

  • Federico
    Federico almost 2 years

    Before diving into the question, some quick background information:
    I have built a small experiment which works together with a computer running Windows 7. On this computer, there is a small webserver serving a webpage continuously updated with status information coming from the experiment. Now this experiment will be displayed at some events (imagine MakerFaire, ...) and I would love if people could use their smartphones (or laptops) to display directly this webpage with as little configuration on their side as possible.

    Basically what I'm trying to achieve is:

    1. Create a Wifi Access Point using the computer's built-in wifi adapter which people can connect to (open or password protected)

    2. Intercept and redirect DNS and/or HTTP requests so that the experiment webpage is displayed when they open a browser (like a captive portal)

    So far I have been able to achieve point 1 using the Hosted Network feature of Windows 7 which works great for the Wifi AP part. However I'm stuck when it comes down to modifying the DHCP answers to provide custom a DNS server which in turn will forward all traffic to my webserver: is there any way to do it?

    A few constraints that I have (otherwise it would be too easy ;-) ):

    • I am stuck with Windows 7 (I know with Linux the problem would have been solved long ago!)
    • The computer is a standalone machine, ie there is no access to other networks or the Internet. Which also means no router or any other external device!

    Any help or suggestions are greatly appreciated!

    • harrymc
      harrymc almost 10 years
      You could give the webserver computer a static IP address inside the network segment (eg. 192.168.0.200) and then on the smartphone address the webpage as http://192.168.0.200/webpage. If you fear a DHCP conflict, modify the router so as to exclude 200 from its range (ie. 192.168.0.0-199). Some routers use addresses of 192.168.1.x.
    • Federico
      Federico almost 10 years
      Maybe that's not explicit enough in my original post, but there is no router or other equipment whatsoever involved: just the Windows PC with its built-in Wifi adapter!
  • Federico
    Federico almost 10 years
    Hi! Thanks for suggesting a DNS server running under Windows. However I think you missed an essential part of the question when you mention the DHCP server settings "on the router": the complete solution (wifi AP + DNS server + DHCP server + webserver) needs to be "self-contained" on the Windows PC...
  • Everett
    Everett almost 10 years
    So you really have 5 questions here: How do you set up a wifi AP in Win7? How do you set up a DNS server in Win7? How do you set up a DHCP server in Win7? How do you set up a web server in Win7? How do you integrate all 4 of these items so that they work together?
  • Federico
    Federico almost 10 years
    I don't think I ever asked any of those questions... The only question is: how can I customize the DHCP replies (so as to include a custom DNS server) distributed by the DHCP server built in the Hosted Network feature of Windows 7?
  • Everett
    Everett almost 10 years
    Yes, you did: : the complete solution (wifi AP + DNS server + DHCP server + webserver) needs to be "self-contained"
  • Federico
    Federico almost 10 years
    Since you like quotes: "I'm stuck when it comes down to modifying the DHCP answers []: is there any way to do it?". I never said I have problems with setting up a DNS server or a webserver...
  • Everett
    Everett almost 10 years
    Wrong: Item 2 in the original question: "Intercept and redirect DNS. " The you listed it again. "(wifi AP + DNS server + DHCP server + web server)" See where you put DNS server in there? Are we done here?