Private Network on CentOS

创建Vultr云主机(CentOS)时, 可以选择启用Private Network. 根据官方提供的文档, 配置私有网络eth1.

# Settings > IPv4 > Private Network
Private IP: 10.99.0.10  
Netmask: 255.255.0.0  
Gateway: n/a  
MTU: 1450  

NetworkManager

因为NM没有启用, 所以先启用它.

$ cd /etc/sysconfig/network-scripts/
$ sed -i '/NM_CONTROLLED/s/no/yes/' ifcfg-eth0
$ systemctl --now enable NetworkManager

nmtui (首选)

使用nmtui可视化操作, 不易出错, 强烈推荐.

nmcli (备选)

使用nmtui创建的eth1配置名称为ifcfg-System_eth1, 重命名为ifcfg-eth1后, 需要重新加载NetworkManager才能生效.

$ cd /etc/sysconfig/network-scripts/
$ mv ifcfg-System_eth1 ifcfg-eth1
$ nmcli connection reload

$ nmcli device
DEVICE       TYPE      STATE      CONNECTION  
eth0         ethernet  connected  System eth0  
eth1         ethernet  connected  System eth1  
lo           loopback  unmanaged  --

$ nmcli connection
NAME         UUID                                  TYPE            DEVICE  
System eth1  608d2415-ee01-4992-9221-f6f0a217337f  802-3-ethernet  eth1  
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0  

ifcfg-eth1

HWADDR=5A:00:00:3C:54:AE  
TYPE=Ethernet  
BOOTPROTO=none  
DEFROUTE=no  
IPV4_FAILURE_FATAL=no  
IPV6INIT=no  
IPV6_AUTOCONF=yes  
IPV6_DEFROUTE=yes  
IPV6_PEERDNS=yes  
IPV6_PEERROUTES=yes  
IPV6_FAILURE_FATAL=no  
NAME="System eth1"  
UUID=608d2415-ee01-4992-9221-f6f0a217337f  
ONBOOT=yes  
MTU=1450  
IPADDR=10.99.0.10  
PREFIX=16