root@wbb-virtual-machine:~# cp -p /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bk.20200326
root@wbb-virtual-machine:~# 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.
# 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: true
version: 2
root@wbb-virtual-machine:~#
root@wbb-virtual-machine:~# 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.
# 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
addresses: [192.168.1.85/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,114.114.114.114]
version: 2
root@wbb-virtual-machine:~#
root@wbb-virtual-machine:~# netplan --debug apply
** (generate:4578): DEBUG: 06:14:11.521: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:4578): DEBUG: 06:14:11.542: starting new processing pass
** (generate:4578): DEBUG: 06:14:11.543: ens33: setting default backend to 1
** (generate:4578): DEBUG: 06:14:11.543: Configuration is valid
** (generate:4578): DEBUG: 06:14:11.544: Generating output files..
** (generate:4578): DEBUG: 06:14:11.545: NetworkManager: definition ens33 is not for us (backend 1)
(generate:4578): GLib-DEBUG: 06:14:11.546: posix_spawn avoided (fd close requested)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:ens33 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets:
ens33:
addresses:
- 192.168.1.85/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 114.114.114.114
vlans: {}
wifis: {}
DEBUG:Skipping non-physical interface: lo
DEBUG:device ens33 operstate is up, not changing
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for ens33
root@gnu-virtual-machine:~#
root@wbb-virtual-machine:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:28:3f:2a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.85/24 brd 192.168.1.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe28:3f2a/64 scope link
valid_lft forever preferred_lft forever
root@wbb-virtual-machine:~# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=55 time=6.40 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=54 time=6.42 ms (DUP!)
From 192.168.1.227 (192.168.1.227): icmp_seq=2 Redirect Network(New nexthop: _gateway (192.168.1.1))
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=55 time=8.13 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=54 time=8.13 ms (DUP!)
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, +2 duplicates, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.396/7.267/8.133/0.862 ms
root@wbb-virtual-machine:~#