具有 2 个 IP 的网卡,应用程序只能侦听 1 个 IP,希望路由其他 IP

具有 2 个 IP 的网卡,应用程序只能侦听 1 个 IP,希望路由其他 IP

我运行一个 ubuntu 服务器。它有 1 个 NIC 和 2 个 IP 地址。它看起来像这样:

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.23
netmask 255.255.255.0
gateway 192.168.1.254

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
address 101.0.140.53
netmask 255.255.255.248
gateway  101.0.140.54

我可以将应用程序绑定到任一 IP 地址,但不能同时绑定到两者。因此,当我将其绑定到 WAN 时,LAN 上的任何人都无法连接(路由器不允许连接)。因此 WAN 用户连接到地址 101.0.140.53。LAN 用户可以使用 192.168.1.23 进行连接。

我想绑定到 WAN 地址并设置 iptable 以将 192.168.1.23 直接移动到 101.0.140.53。或者任何其他方法。

任何帮助都很好

答案1

绑定到0.0.0.0。这意味着所有 IP。

相关内容