ipv6网络设置

来源:互联网 发布:linux将服务开机启动 编辑:程序博客网 时间:2024/04/29 19:52
ipv6网络的管理
建立ipv6地址
[root@localhost Desktop]# nmcli connection add con-name westos ifname eth0 type ethernet ip6 2017::1/48
Connection 'westos' (84efb7eb-dd9b-4c1c-b4da-069648899056) successfully added.

[root@localhost Desktop]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 2017::1  prefixlen 48  scopeid 0x0<global>
        inet6 fe80::5054:ff:fe00:250b  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:25:0b  txqueuelen 1000  (Ethernet)
        RX packets 23  bytes 1278 (1.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 60  bytes 10712 (10.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 8  bytes 556 (556.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 556 (556.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
有时会出现ipv4地址,若只想出现ipv6的ip:
[root@localhost Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-westos
TYPE=Ethernet
BOOTPROTO=none     ######改为none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=2017::1/48
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=westos
UUID=84efb7eb-dd9b-4c1c-b4da-069648899056
DEVICE=eth0
ONBOOT=yes

[root@localhost Desktop]# systemctl restart network
[root@localhost Desktop]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
***     inet6 2017::1  prefixlen 48  scopeid 0x0<global>
        inet6 fe80::5054:ff:fe00:250b  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:25:0b  txqueuelen 1000  (Ethernet)
        RX packets 23  bytes 1278 (1.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 11952 (11.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 12  bytes 976 (976.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 976 (976.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

检测ipv6网络是否可通:
[root@localhost Desktop]# ping6 2017::1
PING 2017::1(2017::1) 56 data bytes
64 bytes from 2017::1: icmp_seq=1 ttl=64 time=0.060 ms
64 bytes from 2017::1: icmp_seq=2 ttl=64 time=0.084 ms
64 bytes from 2017::1: icmp_seq=3 ttl=64 time=0.070 ms
64 bytes from 2017::1: icmp_seq=4 ttl=64 time=0.078 ms

查询网关:
[root@localhost Desktop]# route -6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
[::]/96                        [::]                       !n   1024 0     0 lo
0.0.0.0/96                     [::]                       !n   1024 0     0 lo
2002:a00::/24                  [::]                       !n   1024 0     0 lo
2002:7f00::/24                 [::]                       !n   1024 0     0 lo
2002:a9fe::/32                 [::]                       !n   1024 0     0 lo
2002:ac10::/28                 [::]                       !n   1024 0     0 lo
2002:c0a8::/32                 [::]                       !n   1024 0     0 lo
2002:e000::/19                 [::]                       !n   1024 0     0 lo
2017::/48                      [::]                       U    256 0     0 eth0
3ffe:ffff::/32                 [::]                       !n   1024 0     0 lo
fe80::/64                      [::]                       U    256 0     0 eth0
[::]/0                         [::]                       !n   -1  1     1 lo
localhost/128                  [::]                       Un   0   1     0 lo
2017::1/128                    [::]                       Un   0   1     9 lo
fe80::5054:ff:fe00:250b/128    [::]                       Un   0   1     0 lo
ff00::/8                       [::]                       U    256 0     0 eth0
[::]/0                         [::]                       !n   -1  1     1 lo

查看ipv6网络状态:
[root@localhost Desktop]# netstat -antlpe6
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp6       0      0 ::1:25                  :::*                    LISTEN      0          20745      1342/master         
tcp6       0      0 :::53377                :::*                    LISTEN      29         20320      1253/rpc.statd      
tcp6       0      0 :::111                  :::*                    LISTEN      0          19652      1149/rpcbind        
tcp6       0      0 :::22                   :::*                    LISTEN      0          20346      1070/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      0          29160      1828/cupsd          

查看ipv4网络状态:
[root@localhost Desktop]# netstat -antlpe4
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      0          20744      1342/master         
tcp        0      0 0.0.0.0:54377           0.0.0.0:*               LISTEN      29         20312      1253/rpc.statd      
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      0          19649      1149/rpcbind        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          20344      1070/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      0          29161      1828/cupsd         

查看全部的网络状态:netstat -antlpe

0 0
原创粉丝点击