The function of Auto popup after mobile phone connected to WiFi hotspot

Source: Internet
Author: User

Compiling a bind DNS server using buildroot

using buildroot to make the file system is very convenient , the compiled file system is directly available , without adding scripts and other troublesome work , A lot of libraries and apps are available
add directly to the file system , such as commonly used udhcpc,tftp,apache,lighttpd,php , etc. . .

1, to buildroot directory to execute make arch=arm menuconfig

(1) configuring CPU parameters

Little endian refers to small-end storage;

the binary format is ELF;

CPU is cortex-a5;

Cross tool support EABIHF;

floating-point book processing uses Vfp-v4;

Adopt a streamlined instruction set THUMB2;

(2) specifying the cross-compilation tool

(3) Check the open source software to be compiled

(4) Save exit, execute make to compile;

2.Copy the compiled binary execution file and the required library files to the Development Board

/usr/local/sbin , /usr/local/bin , /usr/local/include , / Usr/local/lib , /usr/local/share/man The newly generated bind -related files are copied to the same directory as the target machine.

3,bind this DNS Domain name resolution server after the transplant , execute the following statement to enable the service

Named-c named.conf &

-C refers to the file address of the configuration script named.conf

Named.conf mainly has the following content

Zone "localhost" in {
Type master;
File "Localhost.zone";
allow-update {none;};
};
Zone "0.0.127.in-addr.arpa" in {
Type master;
File "Named.local";
allow-update {none;};
};
Zone "test.com" in {
Type master;
File "Test.zone";
allow-update {none;};
};

Zone "." {
Type master;
File "Rtk.zone";
allow-update {none;};
};

last zone "." I wrote, that all the domain name to use this to parse, parsing files placed in Rtk.zone inside;

The main contents of Rtk.zone are as follows:

@ in SOA ns.domain.com. Hostmaster.domain.com. (

1053891162
3H
15M
1W
1D)
In NS 10.1.1.1

* in A 10.1.1.1

above * 10.1.1.1 Yes ip RTK ip

After the above toss, now the phone connected to Rtk wifi dns Intercept, the mobile phone access to all the domain name is forced to parse to RTK ip address, if RTK web server, you will see web Web page.

but to implement the Auto popup function, there is one more step that needs to be done, which is to configure the Web server to implement http redirection so that the http header becomes 302 , so that the phone will automatically pop up the window. Schematic diagram is as follows:

The implementation of HTTP redirection is actually very simple, as long as the server's configuration script to add such a statement,

Url.redirect = ("^/(. *)" = "HTTP://10.1.1.1/RTK",)

The meaning of this statement is to reassign all URLs to an address assigned to the rtk directory. This allows for a simple redirection function.

this time, the mobile phone connected to the WiFi , is automatically pop up the RTK directory of a index.html page, the Web site is RTK 's homepage.

extension: If this time to access the external network how to do, in fact, is also very simple, as long as the access to the domain name URL to resolve the IP address written in named.conf Domain name configuration script inside.

[Email Protected]:host www.baidu.com

Www.baidu.com is a alias for www.a.shifen.com.

Www.a.shifen.com has address 112.80.248.73

Www.a.shifen.com has address 112.80.248.74

in theUbuntuon the passHostView the domain name orURLthe correctIPaddress, and then put thisIPaddress is written toDNSthe configuration file inside, so that once the user accesses thisURLit will be resolved into the correspondingIPaddress. Suppose the user accesses thewww.baidu.com, then it will be parsed into112.80.248.73thisIP. In fact, this is the local LANDNSthe principle.

Suppose we have a wifi nic wlan0 3G nic ppp0 ppp0 will have its own ip can be connected to the extranet. wifi as a hotspot, all the devices that access it will be on the same LAN, but the obvious and ppp0

then we need to forward the packets received from Wlan0 to the 112.80.248.73 packets to ppp0, and disguise themselves as from ppp0 the data emitted.

By defining the flow of data, you know what tables and chains are on the link. Then we first select the NAT table, because only it can do the URL conversion, and then deeper, we know that this process,the prerouting of theNat table is the concrete implementation " Camouflage "function.

Specific practices:

1. Enable forwarding function

Echo 1 >/proc/sys/net/ipv4/ip_forward

2. Set forwarding Nat

Iptables-t nat-a postrouting-d 112.80.248.73-p tcp-j masquerade-o ppp0

Iptables-t nat-a postrouting-d 112.80.248.73-p udp-j masquerade-o ppp0

the parameter after-t specifies which table to modify, we select Nat

- A describes how rules are added,append"append"

Postrouting, explaining the modified chain

-D is one of the matching rules that represents the destination IP

-P is the network protocol

-jjump, refers to which target is to be processed

Masquerade is a disguise that automatically detects the egress IP andthen disguises the packet as a data request from ppp0

-O Egress card

through this method, we can access a URL of the external network , such as Baidu Map of the API, the sea, such as the network.

The function of Auto popup after mobile phone connected to WiFi hotspot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.