Ubuntu 18.04 配置静态IP地址

177 篇文章 4 订阅

1,系统版本

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

2,修改IP配置文件

  • /etc/netplan 配置文件目录
# cat 01-network-manager-all.yaml 
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp9s0f0:
      dhcp4: no
      addresses: [192.168.0.112/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [114.114.114.114]
  • 重启网络服务
# netplan apply

3,Ubuntu 18.04.4

# cat /etc/issue
Ubuntu 18.04.4 LTS \n \l
  • 默认配置
# cat /etc/netplan/50-cloud-init.yaml
# 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:
        eno2:
            dhcp4: true
    version: 2
  • 应用配置
netplan apply
network:
    ethernets:
        eno1:
            dhcp4: true
        eno2:
            dhcp4: no
            addresses: [192.168.0.11/24]
            gateway4: 192.168.0.1
            nameservers:
                addresses: [114.114.114.114]
    version: 2
systemctl status  systemd-networkd
netplan --debug apply
network:
    renderer: networkd
    ethernets:
        eno1:
                dhcp4: no
                addresses: [192.168.0.100/24]
                gateway4: 192.168.0.1
                nameservers:
                    addresses: [114.114.114.114]
        eno2:
                dhcp4: no
                addresses: [192.168.0.101/24]
                gateway4: 192.168.0.1
                nameservers:
                    addresses: [114.114.114.114]

    version: 2

参考:

  1. ubuntu18.04LTS设置静态IP
  2. Ubuntu 18.04 LTS 使用 Netplan 配置网络教程
  3. How to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值