강찬희*_*강찬희 8 server networking netplan
好的,我的文件位于 /etc/netplan/50-cloud-init.yaml 我将 IP 地址更改为静态 IP 地址,如下所示:
network:
version: 2
renderer: netwokrd
ethernets:
dhcp4: no
dhcp6: no
addresses: [10.0.2.100/24]
gateway4: 10.0.2.1
nameservers:
addresses: [10.0.2.100]
Run Code Online (Sandbox Code Playgroud)
然后,我输入 sudo netplan apply ,没有任何错误消息。但是,当我输入 ifconfig 时,它仍然在 enp0s3 上重新发送过去的 IP 地址。大家知道为什么会这样吗?
Netplan 对 .yaml 文件的格式很挑剔。不要试图“漂亮”它们。
是50-cloud-init.yaml唯一的 .yaml 文件/etc/netplan吗?
所以编辑你的 .yaml 文件看起来像这样......
network:
version: 2
renderer: networkd # note the correct spelling
ethernets:
enp0s3: # identify the proper interface
addresses: [10.0.2.100/24]
gateway4: 10.0.2.1
nameservers:
addresses: [10.0.2.100] # this is probably the wrong address
addresses: [8.8.8.8, 8.8.4.4] # use something like this instead
Run Code Online (Sandbox Code Playgroud)
然后做:
sudo netplan generate # generate the config files
sudo netplan apply # apply the new configuration
reboot # reboot the computer
Run Code Online (Sandbox Code Playgroud)
并重新检查您的ifconfig输出。
注意:如果是我,我会让 NetworkManager 管理这个接口,并将静态地址信息设置到“有线连接”配置文件中。
network:
version: 2
renderer: NetworkManager
Run Code Online (Sandbox Code Playgroud)
然后做:
sudo netplan generate # generate the config files
sudo netplan apply # apply the new configuration
reboot # reboot the computer
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22246 次 |
| 最近记录: |