今天比较无聊,然后脑洞大开,有一只小鸡给了/64个IPV6地址,为什么不全部配置到小鸡上呢?后来一想不对啊,/64 大概有:18,446,744,073,709,551,616多个IP地址,全部配置到小鸡上,可想而知了,网卡数据包处理都要把小鸡玩炸。。。,那么最好的解决办法呢是应该,配置多个IPV6到小鸡即可。
临时添加,重启失效:
[root@test ~]# ip -6 addr add 2a03:1:10:10a6::2/64 dev eth0
[root@test ~]# ip -6 addr add 2a03:1:10:10a6::3/64 dev eth0
[root@test ~]# ip -6 addr add 2a03:1:10:10a6::4/64 dev eth0
###脚本批量添加:
[root@test ~]# vi /home/ipv6add.sh
#!/bin/bash
INETP="2a03:1:10:10a6::"
PRE="64"
INTE="eth0"
IP1=/sbin/ip
echo -n "Adding IPv6 addresses..."
for i in {3..3000}
do
$IP1 -6 addr add ${INETP}$(printf '%x\n' $i)/${PRE} dev ${INTE}
done
echo "Done!"
###然后加入到定时任务,开启自启动:@reboot root /home/ipv6add.sh
永久添加,重启有效:在ifcfg-eth0添加多个IPv6:
[root@test ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
IPV6INIT=yes
IPV6ADDR=第一个ipv6/64
IPV6ADDR_SECONDARIES="第二个ipv6/64 第三个ipv6/64 第N个IPV6/64" ###注意中间有空格
IPV6_DEFAULTGW=fe80::1
IPV6_DEFAULTDEV=eth0
DNS3=2001:4860:4860::8888
DNS4=2001:4860:4860::8844
###保存以后,重启网络服务,注意:不要重启小鸡,以免由于网络配置错误导致小鸡远程不上。
systemctl restart network
###ip a 命令查看
[root@test ~]# ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc fq state UP group default qlen 1000
link/ether 00:50:56:a0:4a:d9 brd ff:ff:ff:ff:ff:ff
inet 85.x.x.229/24 brd 85.255.15.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:1:110:27e5:ffff:ffff:ffff:ffff/64 scope global
valid_lft forever preferred_lft forever
inet6 2001:1:110:27e5::2/64 scope global
valid_lft forever preferred_lft forever
inet6 2001:1:110:27e5::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fea0:4ad9/64 scope link
valid_lft forever preferred_lft forever
还没有任何评论,你来说两句吧