我将配置从 dhcp 更改为静态 (192.168.0.17),但仍获得 dhcp 分配的 (192.168.0.141) IP。我不知道还能在哪里检查... 有什么想法吗?
是否配置
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.141 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fe87:6981 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:87:69:81 txqueuelen 1000 (Ethernet)
RX packets 43080139 bytes 55213169928 (55.2 GB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 17923871 bytes 1406116280 (1.4 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 56350 bytes 6166732 (6.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 56350 bytes 6166732 (6.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
纳米粒子
DEVICE TYPE STATE CONNECTION
ens33 ethernet unmanaged --
lo loopback unmanaged --
/etc/网络/接口
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# Generated by debian-installer.
# The loopback interface
auto lo
iface lo inet loopback
#The primary network interface
auto ens33
iface ens33 inet static
address 192.168.0.17
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
/etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
uname -a
Linux server 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
答案1
在 Ubuntu Server 17.10 中,网络默认由 netplan 处理。我建议您编辑该/etc/netplan/01-netcfg.yaml
文件以读取以下内容:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
dhcp6: no
addresses: [192.168.0.17/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8,192.168.0.1]
通过运行以下命令退出并保存更改:
sudo netplan apply
请注意并遵守间距和缩进。
注释掉所有 ens33 节/etc/network/interfaces
。重新启动。
有改善吗?