我有一个服务器,带有一个IP和一个额外的故障转移IP。 我试图在OS(wget,curl,其他程序等)的任何地方发出请求时将这个故障转移IP设置为“默认”IP,但最终根本没有IP。
我修改了/ etc / network / interfaces并添加了:
auto eth0:0 iface eth0:0 inet static address FAILOVER_IP netmask 255.255.255.255
然后当运行ifconfig我可以看到具有故障转移IP地址的新eth0:0接口。
要设置它作为主要地址,我尝试route delete 0.0.0.0 ,然后route add default eth0:0 。 但是,这使我失去了与服务器的连接,无法使用任何这些地址访问它。
什么是正确的方法来做到这一点?
如果你想改变你的默认网关永久编辑/etc/network/interfaces :
auto eth0 iface eth0 inet static address <primary-ip> netmask <netmask> auto eth0:1 iface eth0:1 inet static address <secondary-ip> netmask <netmask> gateway <gw-ip> dns-nameservers <dns1> dns-nameservers <dns2>
如果您想暂时更改您的默认网关:
route add default gw <ip-address> eth0 route add default gw <ip-address> eth0