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 #生效

相关推荐
sunxunyong1 天前
CGroup配置
linux·运维·服务器
hy____1231 天前
Linux_网络编程套接字
linux·运维·网络
若风的雨1 天前
【deepseek】 Linux 调度延时分析
linux
小夏卷编程1 天前
Ubuntu 20.04.4 宝塔 docker showdoc v3.2 更新到v3.7.3
运维·docker·容器
康康的AI博客1 天前
农业工业变革:如何通过DMXAPI中转提升自动化效率
运维·人工智能·自动化
2301_803554521 天前
linux 以及 c++编程里对于进程,线程的操作
linux·运维·c++
LuDvei1 天前
windows 中 vs code远程连接linux
linux·运维·服务器·windows
石小千1 天前
Ubuntu24.04安装Mysql8
运维·mysql
生活爱好者!1 天前
NAS帮我找回童年的快乐!部署 小游戏
运维·服务器·docker·容器·娱乐
GDAL1 天前
MANIFEST.in简介
linux·服务器·前端·python