Portal Authentication Server Whitelist

Source: Internet
Author: User
Tags strtok


In the Router Portal Authentication module, the pre-authentication user is not able to surf the Internet through the router, but can access the specified domain name,

The Portal authentication module needs to release the IP address of the authentication server, domain name corresponding IP may be multiple, the following program to simulate domain name resolution to obtain multiple IP addresses.

#include <stdio.h> #include <netdb.h> #include <string.h> #include <netinet/in.h> #include < Arpa/inet.h>int add_white_ip_address (char * domain) {int i = 0;struct hostent *he;struct in_addr *h_addr;char ip_addr[6 4] = {0};if (!domain) return-1;he = gethostbyname (domain); if (he = = NULL) {return 0;}  while (he->h_addr_list[i]! = 0) {memset (ip_addr,0x0,sizeof (IP_ADDR));  strcpy (Ip_addr,inet_ntoa (* (struct in_addr *) he->h_addr_list[i]);p rintf ("%s[%d" =%s\n ", domain,i,ip_addr); i++; }return 1;} int Iptables_fw_init (void) {char * p = Null;//char *p_white_domain_list = Nvram_safe_get ("White_domain_list"); Char *p_ White_domain_list = "www.baidu.com;www.sina.com.cn;www.csdn.net;www.126.com;www.kuaiwifi.com"; char White_domain_ LIST_BUF[512] = {0};struct in_addr *parse_addr;if (p_white_domain_list) {strcpy (white_domain_list_buf,p_white_domain _list);p = Strtok (White_domain_list_buf, ";"); if (p) {printf ("p=%s\n", p); add_white_ip_address (P); while (P = strtok (NULL, ";"))! = NULL) {printf ("p =%s\n", p); add_white_ip_address (P);}}} int main () {//add_white_ip_address ("www.baidu.com"); Iptables_fw_init (); return 0;}











Portal Authentication Server Whitelist

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.