在最新的 Ubuntu 上更改默认传出 IP 地址

在最新的 Ubuntu 上更改默认传出 IP 地址

我刚刚在我的 Ubuntu 服务器上设置了第二个 IP 地址,现在我正尝试使用 将默认传出 IP 地址更改为新的 IP 地址 ip route replace default via <old-ip> src <new-ip>

但每当我重新启动网络服务时,它就会更改为旧的 IP 地址。

答案1

是的,这是因为 Ubuntu 在每次启动网络服务时都会动态设置默认路由。您可以打开 /etc/network/interfaces 并在接口下附加命令,如下所示:

post-up ip route replace default via <old-ip> src <new-ip>

答案2

您的意思是您正在尝试更改您的 IP 地址?

https://help.ubuntu.com/lts/serverguide/network-configuration.html

更改 /etc/network/interfaces 中的设置以设置您想要的 IP 地址。只需将 eth0 更改为 eth1 或任何接口即可。

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

相关内容