要在 Ubuntu 系统上添加永久辅助 IP 地址,只需编辑 /etc/network/interfaces 文件并添加所需的 IP 详细信息。
# vi /etc/network/interfaces
# vi /etc/network/interfaces -
# The loopback network interface auto lo iface lo inet loopback -
# The primary network interface auto eth0 iface eth0 inet static address 192.168.56.150 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255 gateway 192.168.56.1 -
auto eth0:1 iface eth0:1 inet static address 192.168.56.151 netmask 255.255.255.0
保存并关闭文件,然后重启网络接口服务。
# service networking restart 或 # ifdown eth0:1 && ifup eth0:1
验证新添加的 IP 地址:
# ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe98:b736/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5 errors:0 dropped:0 overruns:0 frame:0 TX packets:84 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:962 (962.0 B) TX bytes:11905 (11.9 KB) -
eth0:1 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 inet addr:192.168.56.151 Bcast:192.168.56.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 -
eth1 Link encap:Ethernet HWaddr 08:00:27:6a:cf:d3 inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe6a:cfd3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4924 errors:0 dropped:0 overruns:0 frame:0 TX packets:3185 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4037636 (4.0 MB) TX bytes:422516 (422.5 KB) -
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
如何在 Ubuntu 16.04 LTS 中临时添加辅助 IP 地址
正如本文开头所述,网络接口名称从 Ubuntu 15.10 就开始从 ‘ethX’ 更改为 ‘enXXXX’ (enp0s3),所以,替换你的接口名称。
(编辑:ASP站长网)
|