Ubuntu 17.10+禁用netplan

根据: https : //wiki.ubuntu.com/Netplan

我可以通过以下方式禁用netplan:“preseeding netcfg / do_not_use_netplan = true(在启动Ubuntu Server安装介质时将其添加到命令行”

我假设这是通过/etc/default/grub但我在哪里添加“netcfg / do_not_use_netplan = true”?

是否添加到:GRUB_CMDLINE_LINUX

我目前将此设置为:

 GRUB_CMDLINE_LINUX="ipv6.disable=1" 

在“netcfg / do_not_use_netplan = true”中添加到此现有设置的语法是什么?

PS YES,我想删除netplan,所以问题是关于如何做到这一点,而不是为什么。

实现这一目标的确切方法很难,现在可能无法在netplan的早期找到。

我目前将此设置为:

GRUB_CMDLINE_LINUX = “ipv6.disable = 1”

我假设您的意思是/etc/default/grub读取部分:

 # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="ipv6.disable=1"  

我还假设您提供的链接表明您添加了引用的措辞:

 # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="ipv6.disable=1 netcfg/do_not_use_netplan=true"  

我建议你这样做,然后是:

 sudo update-grub 

您还需要:

 sudo apt install ifupdown 

它可能已经安装好了。

最后,手动填写/etc/network/interfaces以按您希望的方式配置网络。

就谷歌而言,安装完成后的确切过程并不存在。 用手指交叉重启!

这些方向也已经过Ubuntu 18.04.1的测试,很可能也适用于使用netplansystemd任何未来版本。

根本不需要使用GRUB,也不需要任何手动文件删除。 在/etc/networking文件和目录中设置的配置将在重新启动后继续存在

这些是经过validation的步骤:

  1. 使用ip l检查您感兴趣的实际接口名称是否为链接 (也称为接口),使用ip a地址。
  2. 使用sudo apt -y install ifupdown
  3. 使用sudo apt -y purge netplan.io
  4. 根据您的需要配置/etc/network/interfaces和/或/etc/network/interfaces.d man 5 interfaces可以提供一些示例帮助)。
  5. 使用sudo systemctl restart networking; systemctl status networking重新启动networking服务sudo systemctl restart networking; systemctl status networking sudo systemctl restart networking; systemctl status networkingsudo /etc/init.d/networking restart; /etc/init.d/networking status sudo /etc/init.d/networking restart; /etc/init.d/networking statusstatus命令的输出应提及active作为其状态。
  6. 命令ip a将显示是否已应用预期的网络配置。
  7. (可选)使用sudo rm -vfr /usr/share/netplan /etc/netplan netplan手动清除netplan配置文件的sudo rm -vfr /usr/share/netplan /etc/netplan

为了“刷新”IP配置,不需要重新启动:从第5步开始,它将处于活动状态。 如果出现问题,请仔细检查接口名称。 典型的IPv4 DHCP配置类似于以下配置:

 auto enp0s3 iface enp0s3 inet dhcp 

虽然可以像这样配置静态IPv4地址:

 auto enp0s3 iface enp0s3 inet static address 192.168.255.42/24 gateway 192.168.255.254 #dns-nameservers 8.8.8.8 208.67.222.222 

请注意, dns-nameservers条目将不起作用(感谢@Velkan指出它!):解析器仍然使用/etc/resolv.conf并且systemd正在提供自己的127.0.0.53解析服务。 所以你可以手动更新它(不需要重新启动网络!):

 nameserver 8.8.8.8 nameserver 208.67.222.222 

但他只是暂时解决方案,在下次重启后消失。

要获得永久性解决方案,您需要编辑/etc/systemd/resolved.conf并在“ [Resolve] ”节中添加如下所示的行:

 DNS=8.8.8.8 208.67.222.222 

请参阅man 5 resolved.conf获取完整文档。

最后,在不太可能的情况下,任何网络服务都没有按预期响应,那么该服务可能需要重新启动。 但这是一种奇怪的非标准网络守护进程行为。