Ubuntu/Debian网络配置(补充篇)

Ubuntu/Debian网络配置补充

在《Ubuntu/Debian网络配置 & Ubuntu禁用自动更新_ubuntu nmtui-CSDN博客》上总结的"配置网络"章节,对于新版本或者"最小化安装"场景,可能不适应,故此本文做一下补充,就不在原有文章上做更新了。

我在《试用Debian12.7和Ubuntu24.4小札-CSDN博客》中也有提及:Debian GNU/Linux 12 (bookworm)和Ubuntu 24.04.1 LTS是现阶段(2024年9月26日)两个发行版的最新版本。"最小化安装"或者"去桌面环境安装"场景下,这俩个发行版默认都没有装NetworkManager网络管理器。

Debian12*还好,仍然可以使用老方法配置:

1、编辑**/etc/network/interfaces**

2、重启networking服务:systemctl restart networking

Ubuntu Server 24.04使用netplan 工具:

1、修改配置文件/etc/netplan/*.yaml(这里的文件名,不同版本可能不一样)

2、执行sudo netplan apply应用;

注: 在/etc/netplan/*.yaml中可能会提及:(但是,我发现重启虚拟机配置并未失效,可能在云环境下需要注意。)

This file is generated from information provided by the datasource. Changes to it will not persist across an instance reboot. To disable cloud-init's network configuration capabilities, write a file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:

network: {config: disabled}

#该文件是由数据源提供的信息生成的。对它的更改将不会在实例重新启动期间持续存在。要禁用cloud-init的网络配置功能,写入/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg文件,如下所示:

network: {config: disabled}

Debian12.7安装NetworkManager

通过移除 `/etc/network/interfaces` 文件中与网络接口相关的配置,您可以将网络接口的管理交给 NetworkManager。这一步骤可以确保您的网络配置由 NetworkManager 统一管理,简化网络配置并提高网络连接的稳定性。记得在每次更改配置前备份原有的配置文件,以防万一。

安装NetworkManager服务

~# apt -y install network-manager

......

0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.

......

The following network interfaces were found in /etc/network/interfaces

which means they are currently configured by ifupdown:

  • ens192

If you want to manage those interfaces with NetworkManager instead

remove their configuration from /etc/network/interfaces.

......

Created symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service -> /lib/systemd/system/NetworkManager.service.

~# nmcli c show

NAME UUID TYPE DEVICE

lo 23c26c96-e70e-4829-bfc5-8fa7f9233544 loopback lo

确保 /etc/network/interfaces 文件不干扰 NetworkManager

备份并修改/etc/network/interfaces,只保留lo接口

~# cp -f /etc/network/interfaces{,_bak}

~# vi /etc/network/interfaces

......

auto lo

iface lo inet loopback

重启networking服务、重启NetworkManager服务

systemctl restart networking

systemctl restart NetworkManager

验证网络状态

检查网络接口是否已经被 NetworkManager 正确管理:

```

~# ip add show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host noprefixroute

valid_lft forever preferred_lft forever

2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000

link/ether 00:50:56:9a:a5:05 brd ff:ff:ff:ff:ff:ff

altname enp11s0

inet 192.168.xx.217/24 brd 192.168.11.255 scope global ens192

valid_lft forever preferred_lft forever

inet6 fe80::250:56ff:fe9a:a505/64 scope link

valid_lft forever preferred_lft forevezzzzz

相关推荐
轻松Ai享生活18 小时前
5 节课深入学习Linux Cgroups
linux
christine-rr19 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
三坛海会大神55519 小时前
LVS与Keepalived详解(二)LVS负载均衡实现实操
linux·负载均衡·lvs
東雪蓮☆19 小时前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
乌萨奇也要立志学C++19 小时前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
绿箭柠檬茶21 小时前
Ubuntu 服务器配置转发网络访问
服务器·网络·ubuntu
风_峰21 小时前
Ubuntu Linux SD卡分区操作
嵌入式硬件·ubuntu·fpga开发
獭.獭.21 小时前
Linux -- 信号【上】
linux·运维·服务器
hashiqimiya21 小时前
centos配置环境变量jdk
linux·运维·centos
hashiqimiya21 小时前
权限更改centos中系统文件无法创建文件夹,使用命令让普通用户具备操作文件夹
linux