一个 NIC(网卡)上的两个 IP

Sam*_*Sam 8 networking ubuntu ip-address

我有一台带有一张网卡的专用服务器。但是我得到了两个IP地址。当我使用简单命令时,sudo ip addr add 188.40.90.88 dev eth0它无法将其视为单独的 IP。我一直在用谷歌搜索试图找到修复程序,但我无法真正找出设置交换机需要哪些软件包,以及如何进行。

我的专用服务器以以下规格运行:

  • 16GB DDR3 内存(英特尔 i7)
  • 操作系统:Ubuntu 14.01

我相信这是最重要的两个;我不知道我的专用服务器有什么网卡,但我知道它支持IEEE 802.1q,这是我在 Ubuntu 网站上发现的。

ear*_*Lon 14

我不太确定你想要完成什么。我假设您的问题可以重新命名为“如何在单个网络接口上设置两个 IP”。

您机器上的每个网络接口都有一个标识符。通常,您从eth0开始,然后逐步向上(eth1、eth2、eth3)。这些都是物理上不同的网卡。

您还可以在每张实体卡上放置虚拟卡。这就是在同一个 NIC 上设置多个 IP 的方式。

要进行设置,您可以使用以下示例,更改地址以满足您的需要 ( /etc/network/interfaces):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


# The primary network interface
auto eth0 eth0:0
allow-hotplug eth0 eth0:0

#eth0
iface eth0 inet static
address 123.123.123.123
netmask 255.255.255.0
gateway 123.123.123.1

#eth0:0 (LAN)
iface eth0:0 inet static
address 212.212.212.212
netmask 255.255.128.0
gateway 212.212.212.1
Run Code Online (Sandbox Code Playgroud)

棘手的部分可能是网络掩码。255.255.255.0如果您不确定,请尝试。


小智 6

If you set a secondary IP for eth0, it should be set to eth0:0:

sudo ip addr add 188.40.90.88 dev eth0:0
Run Code Online (Sandbox Code Playgroud)

  • 请更清楚地解释您的答案。OP如何设置IP?使用哪个命令?编辑什么文件?你能举个例子吗?也许解释一下“eth0:0”是什么意思?我们希望这里的答案是全面的。 (3认同)