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

相关推荐
zqh1767364646912 分钟前
cisp-pte多少钱考一次?cisp-pte报考费用及报考条件一次说清楚!
大数据·运维·服务器·安全·web安全·网络安全
丁总学Java19 分钟前
docker -私有镜像仓库 - harbor安装
运维·docker·容器·harbor
yoona102021 分钟前
《掌握Shell脚本:从入门到精通的实用指南》
linux·区块链·团队开发·个人开发·学习方法
Maann21 分钟前
mobaxterm、vscode通过跳板机连接服务器
运维·服务器
itachi-uchiha23 分钟前
Ubuntu/Debian网络配置(补充篇)
linux·ubuntu·debian
neter.asia37 分钟前
Docker快速部署RabbitMq教程
linux·运维·服务器·docker
Xinan_____1 小时前
Linux——pod的控制器
linux·运维·服务器
w_outlier1 小时前
进程间通信(一)【管道通信(下)】
linux·进程·通信·管道
蒲公英的孩子1 小时前
并行程序设计基础——MPI接口一览
linux·c语言·分布式·负载均衡