Ubuntu 17.10+ 禁用网络计划

10 grub2 netplan

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

我可以通过以下方式禁用网络计划:“预置 netcfg/do_not_use_netplan=true(在启动 Ubuntu 服务器安装媒体时将其添加到命令行”

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

是否添加到:GRUB_CMDLINE_LINUX

我目前将此设置为:

GRUB_CMDLINE_LINUX="ipv6.disable=1"
Run Code Online (Sandbox Code Playgroud)

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

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

Enz*_*zoR 13

这些方向也已针对 Ubuntu 18.04.1 进行了测试,并且很可能也适用于使用netplan和 的任何未来版本systemd

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

这些是经过验证的步骤:

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

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

auto enp0s3
iface enp0s3 inet dhcp
Run Code Online (Sandbox Code Playgroud)

而静态 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
Run Code Online (Sandbox Code Playgroud)

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

nameserver 8.8.8.8
nameserver 208.67.222.222
Run Code Online (Sandbox Code Playgroud)

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

要获得永久解决方案,您需要编辑/etc/systemd/resolved.conf并将这样的一行添加到“ [Resolve]”节:

DNS=8.8.8.8 208.67.222.222
Run Code Online (Sandbox Code Playgroud)

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

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

  • 它在重新启动后工作。 (2认同)

chi*_*555 5

做到这一点的确切方法很难,在 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"
<snip>
Run Code Online (Sandbox Code Playgroud)

我还假设您提供的链接建议您添加引用的措辞:

# 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"
<snip>
Run Code Online (Sandbox Code Playgroud)

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

sudo update-grub
Run Code Online (Sandbox Code Playgroud)

您还需要:

sudo apt install ifupdown
Run Code Online (Sandbox Code Playgroud)

它可能已经安装。

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

就 Google 和我所能找到的,在安装后执行此操作的确切过程不存在。用手指交叉重新启动!