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

相关推荐
Ronin305几秒前
【Linux网络】应用层协议HTTP
linux·网络·http·应用层协议
chen_note32 分钟前
Kubernetes1.23版本搭建(三台机器)
运维·容器·kubernetes·云计算·kubepi
花落已飘38 分钟前
openEuler WSL2容器化开发实战:Docker Desktop集成与应用部署
运维·docker·容器
伊卡洛斯az1 小时前
vim的跳转看头文件与分屏
linux·编辑器·vim
paopao_wu2 小时前
DeepSeek-OCR实战(01):基础运行环境搭建-Ubuntu
linux·人工智能·ubuntu·ai·ocr
betazhou2 小时前
基于Linux环境使用ogg19版本从oracle 19c ADG备库远程同步数据
linux·运维·oracle·goldengate·adg·远程抽取
路由侠内网穿透.2 小时前
本地部署消息代理软件 RabbitMQ 并实现外部访问( Windows 版本 )
linux·运维·服务器·远程工作
wanhengidc2 小时前
海外云手机是指什么
运维·服务器·游戏·智能手机·云计算
Fanmeang2 小时前
华为防火墙基础功能详解:构建网络安全的基石
运维·网络·安全·华为·防火墙·策略·安全域
孙同学_2 小时前
【Linux篇】System V IPC详解:共享内存、消息队列与信号量
linux·服务器