2017年5月21日 星期日

CentOS 7.3 設定 IPv6 固定 IP

server IP: 2001:288:5468::2/64
default gateway: 2001:288:5468::ff

設定前
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 62:34:62:38:61:62 brd ff:ff:ff:ff:ff:ff
    inet 163.17.50.131/25 brd 163.17.50.255 scope global ens18
       valid_lft forever preferred_lft forever
    inet6 2001:288:5468:0:14b6:c7fd:2131:5a43/64 scope global deprecated noprefixroute dynamic
       valid_lft 2488333sec preferred_lft 0sec
    inet6 fe80::3190:8336:231d:9dd3/64 scope link
       valid_lft forever preferred_lft forever
    inet6 fe80::b3af:dd64:6f0b:1002/64 scope link tentative dadfailed
       valid_lft forever preferred_lft forever


編輯設定檔
# vi /etc/sysconfig/network-scripts/ifcfg-ens18
...修改...
IPV6_AUTOCONF=no
...增加...
IPV6ADDR=2001:288:5468::2/64
IPV6_DEFAULTGW=2001:288:5468::ff
...

重啟網路介面
# systemctl restart network

設定後
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 62:34:62:38:61:62 brd ff:ff:ff:ff:ff:ff
    inet 163.17.50.131/25 brd 163.17.50.255 scope global ens18
       valid_lft forever preferred_lft forever
    inet6 2001:288:5468::2/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::3190:8336:231d:9dd3/64 scope link
       valid_lft forever preferred_lft forever
    inet6 fe80::b3af:dd64:6f0b:1002/64 scope link tentative dadfailed
       valid_lft forever preferred_lft forever


測試自己
# ping6 ::1
測試 GW
# ping6 2001:288:5468::ff
測試外部
# ping6 2001:288:5400:2::1
# ping6 www.ipv6.hinet.net

PS:實作時忘了將測試機 IPV 6 關掉,結果 IP 相衝,無法 ping6 到外部:
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 62:34:62:38:61:62 brd ff:ff:ff:ff:ff:ff
    inet 163.17.50.131/25 brd 163.17.50.255 scope global ens18
       valid_lft forever preferred_lft forever
    inet6 2001:288:5468::2/64 scope global tentative dadfailed
       valid_lft forever preferred_lft forever
    inet6 fe80::3190:8336:231d:9dd3/64 scope link
       valid_lft forever preferred_lft forever
    inet6 fe80::b3af:dd64:6f0b:1002/64 scope link tentative dadfailed
       valid_lft forever preferred_lft forever

沒有留言:

張貼留言