如何使用 iproute2 启动非引导 (ONBOOT=no) 网络接口?

Bel*_*dez 7 networking rhel centos iproute

有一个在启动时不出现的网络接口:

[belminf@tito ~]$ grep ONBOOT /etc/sysconfig/network-scripts/ifcfg-enp0s3
ONBOOT=no
Run Code Online (Sandbox Code Playgroud)

我知道我可以为 DHCP 执行以下操作:

 [belminf@tito ~]$ ip link set enp0s3 up
 [belminf@tito ~]$ dhclient enp0s3
Run Code Online (Sandbox Code Playgroud)

或者,对于静态 IP:

 [belminf@tito ~]$ ip link set enp0s3 up
 [belminf@tito ~]$ ip addr add 192.0.2.11/24 dev enp0s3
Run Code Online (Sandbox Code Playgroud)

但是,有没有办法从/etc/sysconfig/network-scripts/ifcfg-enp0s3类似的地方加载配置ifup ensp0s3

rza*_*eff 7

在 RHEL 7+ 中,您必须使用nmcli命令进行永久更改。nmcli命令/etc/sysconfig/network-scripts/ifcfg-con_name首先使用文件,当您修改连接属性时,nmcli它也会写入ifcfg-con_name文件。因此,要自动启动连接,您需要使用以下内容:

nmcli con mod enp0s3 connection.autoconnect yes
Run Code Online (Sandbox Code Playgroud)

它将ONBOOT属性更改为yes.

为了加载新更改的配置文件,您需要使用(否则它将在下次启动时加载):

nmcli con down enp0s3
nmcli con up enp0s3
Run Code Online (Sandbox Code Playgroud)

祝你好运!