Closed GoogleCodeExporter closed 9 years ago
这个方案把无状态地址分配做成有状态的了,有点danteng,不�
��确实能解决问题,有助于NAPT66的推广。
今天下午看了shell编程的资料,现学现用,写了个脚本。希望
高手能帮忙改进一下它。
#!/bin/sh
link_addr=$(ifconfig $1 | grep 'Scope:Link$' | awk '{ print $3}')
rdisc6 -i $1 > /tmp/router_ad.tmp
prefix=$(cat /tmp/router_ad.tmp | grep '^ Prefix*' | awk -F ": " '{ print $2 }'
| awk -F "/" '{ print $1 }')
ip6_addr=${prefix%*:}${link_addr##*::}
ip -6 addr add ${ip6_addr} dev $1
ip6_gw=$(cat /tmp/router_ad.tmp | grep '^ from' | awk '{ print $2 }')
ip -6 route add default via ${ip6_gw} dev $1
Original comment by Mzwei...@gmail.com
on 20 Mar 2011 at 9:07
以上脚本还存在一些问题:
1 未处理RA有效期属性;
2 未处理某些非标准的子网前缀。
不过应该适用于大部分情形了,希望高手能帮忙改进它。
Original comment by Mzwei...@gmail.com
on 20 Mar 2011 at 9:10
修正一下脚本中的参数错误。
rdisc6是不用 -i 参数的,正确的用法是rdisc6 <interface>。
修正后的saac.sh如下,用法仍为./saac <interface>。
#!/bin/sh
link_addr=$(ifconfig $1 | grep 'Scope:Link$' | awk '{ print $3}')
rdisc6 $1 > /tmp/router_ad.tmp
prefix=$(cat /tmp/router_ad.tmp | grep '^ Prefix*' | awk -F ": " '{ print $2 }'
| awk -F "/" '{ print $1 }')
ip6_addr=${prefix%*:}${link_addr##*::}
ip -6 addr add ${ip6_addr} dev $1
ip6_gw=$(cat /tmp/router_ad.tmp | grep '^ from' | awk '{ print $2 }')
ip -6 route add default via ${ip6_gw} dev $1
Original comment by Mzwei...@gmail.com
on 28 Mar 2011 at 1:38
嫌以前的脚本太慢,再修改了一次,让rdisc6收到一个ra报文后
就返回。我保存在/usr/sbin/slaac中当系统命令了。
#!/bin/sh
link_addr=$(ifconfig $1 | grep 'Scope:Link$' | awk '{ print $3}')
rdisc6 $1 -1 > /tmp/router_ad.tmp
cat /tmp/router_ad.tmp
prefix=$(cat /tmp/router_ad.tmp | grep '^ Prefix*' | awk -F ": " '{ print $2 }'
| awk -F "/" '{ print $1 }')
ip6_addr=${prefix%*:}${link_addr##*::}
ip -6 addr add ${ip6_addr} dev $1
ip6_gw=$(cat /tmp/router_ad.tmp | grep '^ from' | awk '{ print $2 }')
ip -6 route add default via ${ip6_gw} dev $1
Original comment by Mzwei...@gmail.com
on 19 Apr 2011 at 3:39
你好,不走内核的话,速度会不会变慢?
Original comment by q741...@gmail.com
on 25 May 2011 at 11:40
> 你好,不走内核的话,速度会不会变慢?
This issue is just about the network autoconfiguration. Packet forwarding is
achieved by kernel anyhow.
Original comment by Mzwei...@gmail.com
on 25 May 2011 at 11:54
Original comment by Mzwei...@gmail.com
on 28 May 2011 at 1:52
Original issue reported on code.google.com by
Mzwei...@gmail.com
on 18 Mar 2011 at 10:20