原文链接:
hello,大家好啊!继之前我们讨论了如何在麒麟KYLINOS上禁用IPv6之后,今天我要给大家带来的是在统信UOS操作系统上禁用IPv6的方法。IPv6是最新的网络通信协议,但在某些特定的网络环境或测试场景中,可能需要禁用IPv6以确保兼容性或满足其他需求。本文将介绍在统信UOS上通过命令行的两种方式来禁用IPv6。让我们开始吧
注意事项
一、使用ipv6后的现象
1.查看系统信息
pdsyw@pdsyw-PC:~/Desktop$ cat /etc/os-version
[Version]
SystemName=UOS Desktop
SystemName[zh_CN]=统信桌面操作系统
ProductType=Desktop
ProductType[zh_CN]=桌面
EditionName=Professional
EditionName[zh_CN]=专业版
MajorVersion=20
MinorVersion=1060
OsBuild=11018.101.100
pdsyw@pdsyw-PC:~/Desktop$ uname -a
Linux pdsyw-PC 4.19.0-amd64-desktop #6108 SMP Wed Sep 13 13:27:25 CST 2023 x86_64 GNU/Linux
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ ping www.baidu.com
PING www.baidu.com(240e:e9:6002:15a:0:ff:b05c:1278 (240e:e9:6002:15a:0:ff:b05c:1278)) 56 data bytes
64 bytes from 240e:e9:6002:15a:0:ff:b05c:1278 (240e:e9:6002:15a:0:ff:b05c:1278): icmp_seq=1 ttl=52 time=197 ms
64 bytes from 240e:e9:6002:15a:0:ff:b05c:1278 (240e:e9:6002:15a:0:ff:b05c:1278): icmp_seq=2 ttl=52 time=39.2 ms
64 bytes from 240e:e9:6002:15a:0:ff:b05c:1278 (240e:e9:6002:15a:0:ff:b05c:1278): icmp_seq=3 ttl=52 time=60.3 ms
64 bytes from 240e:e9:6002:15a:0:ff:b05c:1278 (240e:e9:6002:15a:0:ff:b05c:1278): icmp_seq=4 ttl=52 time=45.7 ms
^C
--- www.baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6ms
rtt min/avg/max/mdev = 39.234/85.441/196.577/64.614 ms
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ ping -4 www.baidu.com
PING www.a.shifen.com (180.101.50.188) 56(84) bytes of data.
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=1 ttl=50 time=52.5 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=2 ttl=50 time=108 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=3 ttl=50 time=46.9 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=4 ttl=50 time=54.4 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6ms
rtt min/avg/max/mdev = 46.913/65.411/107.818/24.638 ms
pdsyw@pdsyw-PC:~/Desktop$
4.查看网卡信息,wlp5s0上有ipv6的信息
pdsyw@pdsyw-PC:~/Desktop$ ifconfig
enp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 38:f7:cd:c4:72:9f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 46 base 0xd000
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 1000 (Local Loopback)
RX packets 724 bytes 58768 (57.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 724 bytes 58768 (57.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.247 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::d3a3:a08e:e3bb:90a3 prefixlen 64 scopeid 0x20<link>
inet6 240e:46d:8810:209b:fe52:8d91:6f5d:52c5 prefixlen 64 scopeid 0x0<global>
ether 50:5a:65:c3:30:79 txqueuelen 1000 (Ethernet)
RX packets 484 bytes 116482 (113.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 482 bytes 65776 (64.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pdsyw@pdsyw-PC:~/Desktop$
二、禁用ipv6的操作
方法一:编辑配置文件禁用ipv6
1.编辑/etc/sysctl.conf 文件,禁用ipv6相关信息
pdsyw@pdsyw-PC:~/Desktop$ sudo vim /etc/sysctl.conf
请输入密码:
验证成功
pdsyw@pdsyw-PC:~/Desktop$ grep disable_ipv6 /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ sudo sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
pdsyw@pdsyw-PC:~/Desktop$
2.查看网卡信息,wlp5s0上无ipv6的信息
pdsyw@pdsyw-PC:~/Desktop$ ifconfig
enp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 38:f7:cd:c4:72:9f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 42 base 0xf000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 35 bytes 3080 (3.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 35 bytes 3080 (3.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.247 netmask 255.255.255.0 broadcast 192.168.0.255
ether 50:5a:65:c3:30:79 txqueuelen 1000 (Ethernet)
RX packets 248 bytes 58035 (56.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 244 bytes 32743 (31.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ ping www.baidu.com
PING www.a.shifen.com (180.101.50.242) 56(84) bytes of data.
64 bytes from 180.101.50.242 (180.101.50.242): icmp_seq=1 ttl=50 time=21.4 ms
64 bytes from 180.101.50.242 (180.101.50.242): icmp_seq=2 ttl=50 time=73.1 ms
64 bytes from 180.101.50.242 (180.101.50.242): icmp_seq=3 ttl=50 time=49.9 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 21.373/48.149/73.129/21.168 ms
pdsyw@pdsyw-PC:~/Desktop$
4.重启系统
5.重启后网卡无ipv6信息
pdsyw@pdsyw-PC:~/Desktop$ ifconfig
enp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 38:f7:cd:c4:72:9f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 42 base 0xf000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 35 bytes 3080 (3.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 35 bytes 3080 (3.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.247 netmask 255.255.255.0 broadcast 192.168.0.255
ether 50:5a:65:c3:30:79 txqueuelen 1000 (Ethernet)
RX packets 248 bytes 58035 (56.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 244 bytes 32743 (31.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pdsyw@pdsyw-PC:~/Desktop$
方法二:使用sed命令禁用ipv6
1.使用sed添加禁用ipv6的信息
pdsyw@pdsyw-PC:~/Desktop$ sudo sed -i '$anet.ipv6.conf.all.disable_ipv6 = 1' /etc/sysctl.conf
请输入密码:
验证成功
pdsyw@pdsyw-PC:~/Desktop$ sudo sed -i '$anet.ipv6.conf.default.disable_ipv6 = 1' /etc/sysctl.conf
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ sudo sed -i '$anet.ipv6.conf.lo.disable_ipv6 = 1' /etc/sysctl.conf
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ sudo sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
pdsyw@pdsyw-PC:~/Desktop$
通过在统信UOS上禁用IPv6,您可以根据特定的网络需求或测试要求调整系统配置。希望这篇文章能帮助到需要在统信UOS上禁用IPv6的朋友们。如果你有任何问题或者更多的经验分享,请在评论区留言,我们一起讨论。
最后,如果你觉得这篇文章有用,请分享转发。点个关注和在看吧,让我们一起探索和学习更多关于Linux系统管理和网络配置的知识!