Ubuntu 18 LTS NetworkManager网络配置

修改/etc/network/interfaces 不生效问题

Ubuntu 18LTS ifupdown has been replaced by netplan(5) on this system
NetworkManager已经废弃interfaces配置,用netplan 配置取代

netplan 安装与配置

apt install netplan.io

详情请看man netplan

Distribution  installers,  cloud  instantiation, image builds for particular devices, or any other way to deploy an operating system put its desired
       network configuration into YAML configuration file(s).  During early boot, the netplan  "network  renderer"  runs  which  reads  /{lib,etc,run}/net‐
       plan/*.yaml and writes configuration to /run to hand off control of devices to the specified networking daemon.
   Examples
       Configure an ethernet device with networkd, identified by its name, and enable DHCP:

              network:
                version: 2
                ethernets:
                  eno1:
                    dhcp4: true

       This is an example of a static-configured interface with multiple IPv4 addresses and multiple gateways with networkd, with equal route  metric  lev‐
       els, and static DNS nameservers (Google DNS for this example):

              network:
                version: 2
                renderer: networkd
                ethernets:
                  eno1:
                    addresses:
                    - 10.0.0.10/24
                    - 11.0.0.11/24
                    nameservers:
                      addresses:
                        - 8.8.8.8
                        - 8.8.4.4
                    routes:
                    - to: 0.0.0.0/0
                      via: 10.0.0.1
                      metric: 100
                    - to: 0.0.0.0/0
                      via: 11.0.0.1
                      metric: 100

examples:

#/etc/netplan/01-netcfg.yaml
network:
    ethernets:
        eth0:
            addresses: [192.168.1.1/24]
            gateway4: 192.168.1.254
            nameservers:
                    addresses: [114.114.114.114,8.8.8.8]
    version: 2

配置生效

sudo netplan apply
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值