ubuntu 设置静态IP

一、

bash 复制代码
ip address

sudo nano /etc/netplan/50-cloud-init.yaml

修改前:

修改后:

bash 复制代码
====================================================================
# 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}
network:
    ethernets:
        enp0s3:
            dhcp4: no
            addresses: [192.168.31.142/24]
            optional: true
            routes:
              - to: default
                via: 192.168.31.1
            nameservers:
              addresses: [114.114.114.114,8.8.8.8]
    version: 2
====================================================================
bash 复制代码
sudo netplan apply #生效

相关推荐
ulias2125 小时前
Linux系统中的权限问题
linux·运维·服务器
青花瓷6 小时前
Ubuntu下OpenClaw的安装(豆包火山API版)
运维·服务器·ubuntu
mzhan0177 小时前
Linux: lock: preempt_count 是一个线程级别的变量
linux·lock
问简7 小时前
docker 镜像相关
运维·docker·容器
Dream of maid7 小时前
Linux(下)
linux·运维·服务器
齐鲁大虾7 小时前
统信系统UOS常用命令集
linux·运维·服务器
Benszen8 小时前
Docker容器化技术实战指南
运维·docker·容器
ZzzZZzzzZZZzzzz…8 小时前
Nginx 平滑升级:从 1.26.3 到 1.28.0,用户无感知
linux·运维·nginx·平滑升级·nginx1.26.3·nginx1.28.0
一叶知秋yyds9 小时前
Ubuntu 虚拟机安装 OpenClaw 完整流程
linux·运维·ubuntu·openclaw
斯普信云原生组10 小时前
Prometheus 环境监控虚机 Redis 方案(生产实操版)
运维·docker·容器