拨号安装几个包就行了
[shell]
sudo apt-get install pppoe pppoeconf
[/shell]
然后设置下
[shell]
sudo pppoeconf
[/shell]
动态域名解析,用的dnspod
[python]
#!/usr/bin/python
#coding=utf-8
import httplib, urllib
import socket
import time
params_www = dict(
login_email="xx@163.com", # replace with your email
login_password="xx", # replace with your password
format="json",
domain_id=2783079, # replace with your domain_od, can get it by API Domain.List
record_id=19154942, # replace with your record_id, can get it by API Record.List
sub_domain="www", # replace with your sub_domain
record_line=u"默认".encode("utf-8"),
)
current_ip = None
def ddns(ip):
params_www.update(dict(value=ip))
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/json"}
conn = httplib.HTTPSConnection("dnsapi.cn")
conn.request("POST", "/Record.Ddns", urllib.urlencode(params_a), headers)
response = conn.getresponse()
data = response.read()
conn.close()
def getip():
sock = socket.create_connection((‘ns1.dnspod.net’, 6666))
ip = sock.recv(16)
sock.close()
return ip
if __name__ == ‘__main__’:
while True:
try:
ip = getip()
if current_ip != ip:
if ddns(ip):
current_ip = ip
except Exception, e:
print e
pass
time.sleep(30)
[/python]