如何在接口上动态启用和禁用 ipv6

LxB*_*gnr 18 configuration ipv6 networking

如何在接口上动态启用和禁用 IPv6,以便在启用时获取链路本地地址?我试过了:

sysctl net.ipv6.conf.all.disable_ipv6=1 禁用 IPv6

sysctl net.ipv6.conf.all.disable_ipv6=0 启用 IPv6。

还有其他方法吗?

小智 9

禁用 IPv6

$ su -
# nano /etc/sysctl.conf
Run Code Online (Sandbox Code Playgroud)

并将这些行添加到 sysctl.conf 文件中

#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
Run Code Online (Sandbox Code Playgroud)

使用新配置保存 sysctl.conf 文件并运行以下命令以启用新设置:

# sysctl -p 
Run Code Online (Sandbox Code Playgroud)

再次检查您的系统

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
Run Code Online (Sandbox Code Playgroud)

现在你应该看到“1?表示您的系统已禁用 IPv6。

来自http://namhuy.net/1419/disable-ipv6-ubuntu-linux-mint.html


fre*_*dyb 8

我认为你的方法是有效的。如果您不想更改每个接口的设置,则可以使用每个接口的设置,例如net.ipv6.conf.eth0.disable_ipv6

我不建议触摸其他任何东西。


小智 5

在 Ubuntu 11.04 中关闭 IPv6

首先,打开或关闭,检查一下

$ ifconfig -a

eth0      Link encap:Ethernet  HWaddr 
          inet addr:  Bcast:  Mask:
          **inet6** addr: fe80::210:f3ff:fe21:722a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:982 errors:0 dropped:0 overruns:0 frame:0
          TX packets:943 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:800461 (800.4 KB)  TX bytes:144524 (144.5 KB)
          Interrupt:20 Memory:f7d00000-f7d20000 

eth1      Link encap:Ethernet  HWaddr  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 Memory:f7c00000-f7c20000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          **inet6** addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1200 (1.2 KB)  TX bytes:1200 (1.2 KB)
Run Code Online (Sandbox Code Playgroud)

其次,关闭,我修改了以下行并修补了 grub

$ grep ipv6 /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"

$ update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.38-11-generic-pae
Found initrd image: /boot/initrd.img-2.6.38-11-generic-pae
Found memtest86+ image: /boot/memtest86+.bin
done
Run Code Online (Sandbox Code Playgroud)

  • 这个答案将告诉 Linux 内核在启动时根本不支持 IPv6。虽然这很好,但我想强调的是,如果不重新启动,就无法重新启用 (4认同)
  • 使用:`$ ip addr` (3认同)