Ubuntu:
sudo vi /etc/netplan/xxx.yaml
:/etc/netplan$ cat 01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
renderer: NetworkManager
ethernets:
enp0s3:
addresses: [192.168.0.160/24]
gateway4: 192.168.0.1
dhcp4: false
nameservers:
addresses: [192.168.0.1]
version: 2
sudo netplan --debug apply
ifconfig -a
dhclient
/etc$ cat resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0 trust-ad
Centos
/etc/sysconfig/network-scripts
[root@localhost network-scripts]# ls
ifcfg-enp0s3
cat ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes
BOOTPROTO=static
#BOOTPROTO=dhcp
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=2ba6581b-8acc-4e84-804f-3711f958a85a
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.0.156
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
NETWORK=192.168.0.1
DNS=192.168.0.1
[root@localhost etc]# cat resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 192.168.0.1