手动配置ipv6地址和静态路由

转发地址:https://www.cnblogs.com/waw/p/16321917.html

1. 手动配置ipv6地址

1.修改配置文件,eth0换成自己的网口名称1

vim /etc/sysconfig/network-scripts/ifcfg-eth0

具体配置信息如下:

TYPE=Ethernet
BOOTPROTO=static
NAME=eno1
DEVICE=eno1
ONBOOT=yes
IPADDR=192.168.31.3
PREFIX=24
GATEWAY=192.168.31.1
  
IPV6INIT=yes        #网卡初始化IPv6协议栈              
IPV6_AUTOCONF=no    #自动获取地址关闭
IPV6_DEFROUTE=yes   #默认路由开启
IPV6_FAILURE_FATAL=yes # 当设置为yes时,如果发生异常系统会尽可能保持连接可用
IPV6ADDR=2001::2/64    #ipv6地址
IPV6_DEFAULTGW=2001::1 #ipv6网关

2.重启服务

service network restart

2.自动获取ipv6地址2

vim /etc/sysconfig/network-scripts/ifcfg-eth0

具体配置信息如下:

TYPE=Ethernet
BOOTPROTO=static
NAME=eno1
DEVICE=eno1
ONBOOT=yes
IPADDR=192.168.31.3
PREFIX=24
GATEWAY=192.168.31.1

IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=yes
DHCPV6C=yes

2.重启服务

service network restart

3. 静态路由34

3.1 临时添加

添加静态网关:

route -A inet6 add 2400:dd0a:1001:151::1/64 gw 2400:dd0a:1001:140::1

删除:

route -A inet6 del 2400:dd0a:1001:151::1 gw 2400:dd0a:1001:140::1

3.2 永久添加

1.修改路由文件

vim /etc/sysconfig/network-scripts/route-eno1

eno1是网卡名称,对照自己的网卡名称

2400:dd0a:1001:151::1/64 via 2400:dd0a:1001:140::1 dev eno1
210.72.151.1/24 via 210.72.140.1 dev eno1

2.重启服务

service network restart

  1. https://blog.csdn.net/qq_43316775/article/details/104925384 ↩︎

  2. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-networkscripts-interfaces#:~:text=One%20of%20the%20most%20common,corresponding%20to%20a%20specific%20interface). ↩︎

  3. https://cloud.tencent.com/developer/article/1485335 ↩︎

  4. https://www.cnblogs.com/zhang1533590225/p/10003433.html ↩︎

posted @ 2023-02-22 10:08  angelfzt  阅读(1184)  评论(0编辑  收藏  举报