此项Achieve the dynamic IP domain name automatic pointing under Linux(在linux下实现动态IP的域名自动指向)

域名指向  时间:2021-02-21  阅读:()

Achieve the dynamic IP domain name automatic pointing under

Linux 在linux下实现动态IP的域名自动指向

China Linux Forum Forum | reviews | cangjingge | CMPP | planMirror plan | online survey software | | warehouse on the |China Linux Forum - article meta

The home page | classified articles | meta search articles |my article | online users

Article meta

The latest article read this topic: 1704

On the last topic, read all the topics, index the next topic,next to the flat pattern tree model, and read the tree modelone by one

Add to favorites | print

Article title in Linux, dynamic IP domain name automaticallypoint to by Gan Jiehan

Respond to the commentary in this article

Posted: David. system (webmaster)

Posted date 09/04/02 12:26 PM

Gan Jiehan, 100 Wenfeng Road, Guangxi, Qinzhou

On the Internet, the user' s domain name and IP address areone-to-one correspondence. But the virtual dial-up access tothe Internet, resulting in a dynamic IP address. This has causedtrouble for computer enthusiasts who don' t have much money toapply for domain names. The previous period, due to the authorof the region' s ADSL instead of virtual dial-up, the troublealso troubled the author for a while. After many debugging,finally realized the dynamic IP address domain name automaticpointing under Linux. Now we will record it and share it withyou:

Before thehttp://www.deerf ield.com/download/dns2go/linux/index.htm isa server for a free domain name, put the dns2go in the/etc/rc.d/rc. local, the boot fixed free domain name. But ADSLto virtual dial-up way, there is no fixed IP address, startdns2go is very troublesome, first use the ifconfig command tofind the ppp0 IP, and thenmodify the IP under/etc/dns2go. conf,and then can start dns2go. It' s inconvenient to use manualoperation every time. It can not be started automaticallywithout anyone' s intervention. Write a C program to solve theproblem, in cases of all procedures are assumed installed inthe /usr/local/bin/, a program written in shell to call the Cprogram, the directory containing xnbh (shell program) , trans(Executive C program compiled) , outfile (intermediatetemporary files) , pppoe.txt (intermediate) , dns2go. conf(typical the configuration file)

The shell program for xnbh is as follows:

Adsl-start# starts the virtual dialer for adls,

The ifconfig ppp0 |grep -v "Link" >/usr/local/bin/pppoe.txt#produces the pppoe. txt file in the directory

The /usr/local/bin/trans# invokes the C program to extract theIP value in the file pppoe.txt, and then replaces the IP valuein the dns2go.conf to produce the intermediate file outfileCP/etc/dns2go. conf/etc/dns2go.confold#backup the originaldns2go. conf file

CP /usr/local/bin/outfile /etc/dns2go. conf # after replacingthe dns2go.conf file

Nohup /usr/local/bin/dns2go >/var/tmp/dns2go. log 2>&1 &#start fixed domain

After executing the second sentence in xnbh, the followingpppoe.txt is generated:

INET addr:218.65.217. 109 P-t-P: 172.0.0. 1

Mask:255.255.255.255

UP, POI NTOPOI NT, RUNNING, NOARP, MULT I CAS T, MTU: 1492, Met r i c: 1RX, packet s:26, errors:0, dropped:0, overruns:0, frame:0TX, packets:27, errors:0, dropped:0, overruns:0, carrier:0Collisions:0 txqueuelen:3

RX bytes:1400 (1.3 Kb) TX bytes:1358 (1.3 Kb)The trans. c program is as follows:

#include <stdio.h>

#include <ctype.h>

(ma i n)

{

F ILE, *fp, *bp, *out;

Int i=0;

Int j;char ip [16] ;char dip [16] ;char na [] = "address =";char inip [24] ;char readln [255] ;char readlnn [255] ;

fp = fopen ("/ usr / local / bin / pppoe.txt", "r") ;if (fgets (readln, 255, fp) ! = = null)

{ (i = 0; i < 16; i + +) ip = readln [20 + in] ;}in = 0;for (i = 0; i < 16; i + +)

{if (ip! = ' ' )

{dip = ip; printf ("ip% d =% c% n" in, ip) ; }else {j = i; printf ("j =% d", j) ; } }for (i = 0; i < = j; i + +) dip = ip;dip [j] = '\ 0' ;printf ("a =% s \ n", dip) ;f c l o s e (fp) ;strcpy (inip, na) ;printf ("inip =% s \ n", inip) ;strcat (inip, dip) ;

printf ("inip =% s \ n", inip) ;fp = fopen ("/ usr / local / bin / dns2go. conf", "r") ;out = fopen ("/ usr / local / outfile", "w") ;while ( ! feof (fp)) {if (fgets (readlnn, 255, fp) ! = = null)i f (strncmp ("addres s = aaa.bbb.ccc.ddd", readlnn, 15)) fputs(readlnn, out) ;else fputs (inip, out) ; }f c l o s e (fp) ;fclose (out) ;

}

在linux下用gcc –o trans trans.c编译通过产生文件trans,dns2go. conf的配vchgob #:

#

# simple configuration file for dns2go linux client

#

# for more information refer to the dns2go.conf manual page#

# global directives

#

# dns2go serverserver = discovery.dns2go.com

# key (required, case sensitive)key = aaaaaa - bbbbbb - ccccccc - ddddd (此项为申请的激活码)# log file (optional, default: syslog)

# log = / var / log / dns2go.txt

# send debug outputs two stdoutdebug

# number of connection attempts (optional, default: 8)# retries = 8

# rate two send heartbeats (in minutes) (optional, default: 0= automati c)

# heartbeat rate = 0

#

# domain directives

#

# fully qualified domain name (required)doma in = xxxxx.dnsgo.com (此项填写固定免费域名)

# static ip address (optional, default: external ip address)address = aaa.bbb.ccc.ddd (此项为假设ip)

# online www alias redirection: choose one of the following:# (optional, default: www. alias resolves two domain ip)# www redirect - url = http: / /. . .

# www redirect gate = 8080

# offline redirect option: choose one of the following# (optional, default: offline status page)

# offline - url = http: / /. . .

# offline - ip = 0.0.0.0

以上xnbh程序若加入/ etc / rc.d / rc. local /中则可以启动时自动启动固定免费域名,

此时你可以启动的apache, ftp, telnet等都可以用此免费域名了,出门在外的朋友可以

很方便找到自己的服务器,熟悉shell的朋友也可以用shell完成c程序的功能, 以上的

程序在redhat7.2上顺利通过.david

Article options: print, put this article in the memorandum, andwhen you have time to reply to friends, share the notificationmoderator

The title of Re: Linux under dynamic IP domain name to by [re:David. ] automatic Gansu Johanna

Respond to the commentary in this article

Posted by: zjohnc (journeyman)

Posting date 09/04/02 04:41 PM

In/etc/ppp/ip-up and/etc/ppp/ip-down Riga, dns2go and dns2go-k, you can automatically follow the new. I have used for morethan 2 months, basically no problem, sometimes can not update,

RackNerd :美国大硬盘服务器促销/洛杉矶multacom数据中心/双路e5-2640v2/64G内存/256G SSD+160T SAS/$389/月

大硬盘服务器、存储服务器、Chia矿机。RackNerd,2019年末成立的商家,主要提供各类KVM VPS主机、独立服务器和站群服务器等。当前RackNerd正在促销旗下几款美国大硬盘服务器,位于洛杉矶multacom数据中心,亚洲优化线路,非常适合存储、数据备份等应用场景,双路e5-2640v2,64G内存,56G SSD系统盘,160T SAS数据盘,流量是每月200T,1Gbps带宽,配5...

WebHorizon($10.56/年)256MB/5G SSD/200GB/日本VPS

WebHorizon是一家去年成立的国外VPS主机商,印度注册,提供虚拟主机和VPS产品,其中VPS包括OpenVZ和KVM架构,有独立IP也有共享IP,数据中心包括美国、波兰、日本、新加坡等(共享IP主机可选机房更多)。目前商家对日本VPS提供一个8折优惠码,优惠后最低款OpenVZ套餐年付10.56美元起。OpenVZCPU:1core内存:256MB硬盘:5G NVMe流量:200GB/1G...

PQS彼得巧 年中低至38折提供台湾彰化HiNet线路VPS主机 200M带宽

在六月初的时候有介绍过一次来自中国台湾的PQS彼得巧商家(在这里)。商家的特点是有提供台湾彰化HiNet线路VPS主机,起步带宽200M,从带宽速率看是不错的,不过价格也比较贵原价需要300多一个月,是不是很贵?当然懂的人可能会有需要。这次年中促销期间,商家也有提供一定的优惠。比如月付七折,年付达到38折,不过年付价格确实总价格比较高的。第一、商家优惠活动年付三八折优惠:PQS2021-618-C...

域名指向为你推荐
安装程序配置服务器失败sql server 2000 安装程序配置服务器失败深圳公交车路线深圳公交路线网站联盟网站联盟的运作流程奇虎论坛奇虎是中国的吗?商标注册查询官网商标注册查询官方网站?什么是云平台什么是云平台管理软件,一个云平台软件应该具有哪些基本功能聚美优品红包聚美优品红包怎么获得网页窗口最大化怎样才能打开网页窗口自己最大化空间装扮免费空间还有那些装扮是免费的?地理空间数据云地理空间数据云下下来的为什么是文件格式
cm域名注册 西安域名注册 网站备案域名查询 日本动态vps 香港vps主机 68.168.16.150 国外空间服务商 轻量 南通服务器 爱奇艺vip免费试用7天 台湾谷歌 免费的asp空间 smtp服务器地址 实惠 网站加速 乐视会员免费领取 789电视剧网 阿里云邮箱怎么注册 锐速 碳云 更多