如何设置网络接口以将 eth0 作为 dhcp 并将 eth0:1 作为静态 ip?

5 networking ubuntu

我正在尝试将我的网络配置为同时具有静态 IP 和 DHCP IP

有问题的系统是 ubuntu 服务器 11.10,只有附加软件是 LAMP 包(网络服务器)和 OpenSSH。

我在下面尝试了这种配置,但结果喜忧参半。有时我只得到 DHCP IP 而不是静态 IP,有时我得到的是静态 IP 而不是 DCHP 一个。

我的配置有问题吗?


自动 lo
iface lo inet 环回

自动 eth0
iface eth0 inet dhcp

自动 eth0:1
iface eth0:1 inet 静态
地址 192.168.0.2
网络掩码 255.255.255.0
网关 192.168.0.1
广播 192.168.0.255

小智 1

尝试删除 auto eth0:1 并将其与第一个添加在一起:

auto eth0 eth0:1
iface eth0 inet dhcp

iface eth0:1 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
broadcast 192.168.0.255
Run Code Online (Sandbox Code Playgroud)

我在为同一个物理 iface 指定两次自动时遇到问题。