最近在Esxi中配置ubuntu18.04 server
记录如何配置静态IP。因为ubuntu18.04
的网络管理程序使用netplan
来管理,所有配置方式也更改了。
查看本机IP
ifconfig -a
查看当前配置文件
cat /etc/netplan/50-cloud-init.yaml
如果要使用静态IP的话,需要修改为下面的样子:
1 | # This file is generated from information provided by |
2 | # the datasource. Changes to it will not persist across an instance. |
3 | # To disable cloud-init's network configuration capabilities, write a file |
4 | # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: |
5 | # network: {config: disabled} |
6 | network: |
7 | ethernets: |
8 | enp0s3: |
9 | addresses: [192.168.199.101/24, ] |
10 | dhcp4: no |
11 | dhcp6: no |
12 | gateway4: 192.168.199.1 |
13 | nameservers: |
14 | addresses: [8.8.8.8, 9.9.9.9] |
15 | version: 2 |
将上述配置改成自己的IP、网关、DNS,最后运行生效配置。
netplan apply