美文网首页
ubuntu18.04LTS server 静态IP设置

ubuntu18.04LTS server 静态IP设置

作者: FsdSoyu | 来源:发表于2019-02-21 13:33 被阅读0次

18.04上新采用的netplan命令。网卡信息配置在/etc/netplan/50-cloud-init.yaml文件,需做如下配置,

root@fsdsoyu:/etc/netplan# cat 50-cloud-init.yaml

# This file is generated from information provided by

# the datasource.  Changes to it will not persist across an instance.

# 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:

        enp9s0:

            addresses: [192.168.11.103/24]

            gateway4: 192.168.11.1

            nameservers:

                    addresses: [192.168.11.1]

            dhcp4: false

    version: 2

然后使用以下命令使配置即时生效,

netplan apply

以上操作均在root用户下进行,如在普通用户,请自行加上sudo。

ip配置信息要按如上格式,使用yaml语法格式,每个配置项使用空格缩进表示层级;

对应配置项后跟着冒号,之后要接个空格,否则netplan命令也会报错。

相关文章

网友评论

      本文标题:ubuntu18.04LTS server 静态IP设置

      本文链接:https://www.haomeiwen.com/subject/axyryqtx.html