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

相关推荐
知白守黑26715 分钟前
Linux磁盘阵列
linux·运维·服务器
维尔切1 小时前
Linux中基于Centos7使用lamp架构搭建个人论坛(wordpress)
linux·运维·架构
tan77º2 小时前
【项目】分布式Json-RPC框架 - 项目介绍与前置知识准备
linux·网络·分布式·网络协议·tcp/ip·rpc·json
丘大梨3 小时前
QT 基础聊天应用项目文档
运维·数据库·系统架构
怀刃3 小时前
C# 内存监控怎么定位问题
运维
TPBoreas3 小时前
Jenkins启动端口修改失败查找日志
运维·服务器·jenkins
正在努力的小河5 小时前
Linux设备树简介
linux·运维·服务器
荣光波比5 小时前
Linux(十一)——LVM磁盘配额整理
linux·运维·云计算
小晶晶京京5 小时前
day35-负载均衡
运维·网络·网络协议·学习·负载均衡
LLLLYYYRRRRRTT5 小时前
WordPress (LNMP 架构) 一键部署 Playbook
linux·架构·ansible·mariadb