squid 配置 支持 ipv6

自己编译安装squid 目前我用的版本是3.4.7 ,老版本的不支持ipv6。
如果想让所有人访问,在最后加上如下一行即可
[code]
http_access allow all
[/code]
最重要的是,更改配置后,要执行命令让它生效
[code]
squid -k reconfigure
or
squid reload
[/code]
这种方式无需重启
此外,可以查看logs 文件下的access.log 和cache.log
来查看运行状况,便于定位错误
配置好后,ipv4接入代理服务器也能访问ipv6网站,ipv4 ipv6畅通无阻

MTU 设置对路由器影响

         MTU=最大传输单元 单位:字节”

我们在使用互联网时进行的各种网络操作,都是通过一个又一个“数据包”传输来实现的。而MTU指定了网络中可传输数据包的最大尺寸,在我们常用的以太网中,MTU是1500字节。超过此大小的数据包就会将多余的部分拆分再单独传输。

通过Ping命令来寻找最佳MTU值。大致方法如下,在命令提示符下执行命令“ping –l MTU –f www.baidu.com”。其中MTU就是要测试的数值。观察返回的结果,如果显示“Packet needs to be fragmented but DF set”则表示过大。不停手动测试,就知道最佳数值是多少了。考虑到数据包头的影响,最终使用的数值要+28,这点请注意。

以Mac 系统下为例 探测 最佳MTU

我用的是电信adsl ,谷假设最佳MTU 1492 默认1480

[code]
//MTU=1480
sudo ping -l 1452 -c 2000 -f baidu.com

//2000 packets transmitted, 41 packets received, 98.0% packet loss

//round-trip min/avg/max/stddev = 362.503/3612.166/5753.365/1629.037 ms

//MTU=1492

sudo ping -l 1464 -c 2000 -f baidu.com

2000 packets transmitted, 503 packets received, +1 duplicates, 74.8% packet loss
round-trip min/avg/max/stddev = 188.259/222.120/400.263/31.073 ms

[/code]

Python的一个包Requests

地址http://docs.python-requests.org/en/latest/

很方便的进行网络编程

例如:

[python]
import requests
payload = {‘key1’: ‘value1’, ‘key2’: ‘value2’}
r = requests.get("http://httpbin.org/get", params=payload)
print r.url
u’http://httpbin.org/get?key2=value2&key1=value1′</pre>
[/python]

树莓派(debian)拨号,并且动态域名解析

拨号安装几个包就行了

[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]