镜像服务 IMS-设置网卡属性为DHCP(Linux):Ubuntu 16.04操作步骤

时间:2023-11-01 16:23:00

Ubuntu 16.04操作步骤

  1. 云服务器上执行以下命令,使用vi编辑器打开“/etc/network/interfaces”文件,查看网卡的网络配置。

    vi /etc/network/interfaces

    • 信息显示所有网卡的网络配置为DHCP模式时,无需重复设置网卡属性,输入:q退出编辑器。
      auto loiface lo inet loopbackauto eth0iface eth0 inet dhcpauto eth1iface eth1 inet dhcp
    • 信息显示网卡的网络配置为静态IP地址时,请执行2
      auto loiface lo inet loopbackauto eth0#iface eth0 inet dhcpiface eth0 inet staticaddress 192.168.1.109netmask 255.255.255.0gateway 192.168.1.1
  2. 按“i”进入编辑模式。
  3. 删除静态IP设置的相关内容,然后将对应的网卡设置为DHCP方式。

    您也可以使用“#”注释掉静态IP设置的相关内容。

    auto loiface lo inet loopbackauto eth0iface eth0 inet dhcp

    如果您有多个网卡,请将剩余网卡按照上述方法设置为DHCP方式。

    auto loiface lo inet loopbackauto eth0iface eth0 inet dhcpauto eth1iface eth1 inet dhcp
  4. 按“ESC”后,输入:wq,按“Enter”。

    保存设置并退出编辑器。

support.huaweicloud.com/usermanual-ims/zh-cn_topic_0030713176.html