服务器ubuntu系统怎么配置ip,如何在 Ubuntu18.04 server 服务器版本的操作系统下 配置IP...

如题,现有需求,为一个server版本的Ubuntu18.04配置 IP 。

在网上查到了 Ubuntu18.04  桌面版本  的配置方法:

$ cat  /etc/network/interfaces

dc6829d90e95934abf750bde55f8f517.png

修改配置文件:

# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 192.168.1.111

gateway 192.168.1.1

netmask 255.255.255.0

auto eth0:1

iface eth0:1 inet dhcp

启用对网卡  eth0  的新IP配置:

sudo ifup eth0:1

==============================================

18.04 server 版本:

给一个网卡配置两个固定IP:

配置网卡文件 /etc/netplan/50-cloud-init.yaml

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

eth0:

addresses: [192.168.100.100/24,172.18.139.54/24]

gateway4:192.168.100.1dhcp4: no

version:2

6ab4759d58eadec45431b6ae890648b8.png

=================================

给一个网卡配置一个IP:

04ebd2a9562454400112c7417863d3c7.png

===================================

重启网络:

sudo netplan apply

===============================

使用 netplan 配置网络时需要注意:

1.  只能使用空格,不能使用tab

2.  冒号: 后面如果接着有值那么冒号和值之间需要有空格

3.  每一项的相同级别的内容需要左对齐

------------------------------------

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值