使用Linux搭建IPV6路由器

版权声明:AshQ https://blog.csdn.net/qq_41565459/article/details/86478024

本文不阐述关于IPv6的基础知识,请自行度娘!

 

实验环境如下:

机房IDC设备-----(eth2)Linux网关(eth3)----北京测试机器Linux

机房IDC设备地址:2401:47C0:1501:FF02::1/126

Linux网关eth22401:47C0:1501:FF02::2/126

Linux网关eth32401:47C0:1501:2::1/64

北京测试机器:2401:47C0:1501:2::2/64

其中Linux网关在香港,跟北京测试机器之间2层专线互联。

1. 加载IPv6模块网关Linux和北京测试机器都要加载

modprobe ipv6

2. 配置Linux网关机器的IPv6地址

ip -6 addr add 2401:47C0:1501:FF02::2/126 dev eth2
ip -6 addr add 2401:47C0:1501:2::1/64 dev eth3

3. 配置Linux网关机器的默认路由

ip -6 route add ::/0 via 2401:47C0:1501:FF02::1 dev eth2

4. 配置Linux网关机器的路由转发和ip6tables

echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
ip6tables -F && service ip6tables save

####
#或者在/etc/sysctl.conf中添加:net.ipv6.conf.all.forwarding=1,
#然后运行sysctl -p
####

最后在/etc/sysconfig/network中添加IPV6FORWARDING=yes,重启网络。

如果这个没加,可能出现如下错误:

“Global IPv6 forwarding is disabled in configuration, but not currently disabled in kernel”

5. 最后按照上述方法配置北京测试机器

ip -6 addr add 2401:47C0:1501:2::2/64 dev eth3
ip -6 route add ::/0 via 2401:47C0:1501:2::1 dev eth3
sysctl -w net.ipv6.conf.all.forwarding=1
ip6tables -F && service ip6tables save

6. 测试IPv6网络连通性

网卡配置文件参数参考:

DEVICE=eth2

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

NETWORKING_IPV6=yes

IPV6_AUTOCONF=no

IPV6INIT=yes

IPV6ADDR=2401:47c0:1501:ff02::2/126

IPV6_DEFAULTGW=2401:47c0:1501:ff02::1

#IPADDR=172.16.133.87

#NETMASK=255.255.255.0

#GATEWAY=172.16.133.254

猜你喜欢

转载自blog.csdn.net/qq_41565459/article/details/86478024