人生最重要的不是努力,而是方向

0%

ubuntu server 设置静态ip

本例子在ubuntu 18.04中可用

在ubuntu server中,找到/etc/netplan/文件夹中的50-cloud-init.yaml文件,配置说明如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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:
ens33: #网卡名称
dhcp4: false # 取消自动获取ip
gateway4: 192.168.6.2 # 服务器ip网关
addresses:
- 192.168.6.131/24 # 服务器ip地址/子网掩码
nameservers: #名称服务器
addresses:
- 192.168.6.2 # dns地址
version: 2


#ubuntu server 18.04 配置静态ip

应用网络配置

1
sudo netplan apply

如果默认得网关做了变更,还需要修改/etc/resolv.conf的内容,将

1
nameserver xxx.xxx.xxx.xxx

修改成当下得网关,即:

1
nameserver 192.168.6.2