gpt4 book ai didi

linux - 如何在 Ubuntu 16.04 上的 OVH VPS 中将 DHCP 接口(interface)更改为静态接口(interface)

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:34:29 25 4
gpt4 key购买 nike

我是 LINUX 的新手,我需要你的帮助,我的 OVH VPS Ubuntu Server 16.04LTS 接口(interface)实际上是在 DHCP 到 STATIC 上

实际上我的/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

# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# See LP: #1262951
source /etc/network/interfaces.d/*.cfg

源码路径/etc/network/interfaces.d/*.cfg只有一个文件名为:50-cloud-init.cfg,这个文件包含:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet dhcp

所以我的 IP 地址是 149.xxx.xxx.61,我需要将其转换为我的 IP 地址的静态 iface ens3。

实际上 ifconfig -a 是:

ens3      Link encap:Ethernet  HWaddr fa:16:3e:ae:e3:83  
inet addr:149.xxx.xxx.61 Bcast:149.xxx.xxx.61 Mask:255.255.255.255
inet6 addr: fe80::xxxx:xxxx:feae:e383/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:894526 errors:0 dropped:0 overruns:0 frame:0
TX packets:297070 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:102187906 (102.1 MB) TX bytes:63602471 (63.6 MB)

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:14743 errors:0 dropped:0 overruns:0 frame:0
TX packets:14743 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:31459525 (31.4 MB) TX bytes:31459525 (31.4 MB)

我该怎么做?

最佳答案

这是一个示例文件,其中包含来 self 的一台服务器的指南:

请注意:并非所有 OVH 服务器都支持 IPv6 或路由 IPv6 地址。您可以在您的控制面板中检查此项,如果您没有看到要使用的地址或不希望 IPv6 支持,请不要包括该部分。要查找路由 IPv6 所需的链接本地地址,可以通过 OVH API 找到它。或通过 converting the interface's MAC address into an appropriate link-local address.

当然,如果您没有任何故障转移 IP 地址,请不要包含该部分。

最后,请注意,在某些基于 VMware 的虚拟机上,网关的最后一个八位字节可能需要是 .254 而不是 .1

auto lo
iface lo inet loopback

#auto ens3
#iface ens3 inet dhcp

#--static IPv4--
auto ens3
iface ens3 inet static
address <main server IP>
netmask 255.255.255.255
broadcast <main server IP>
gateway <main server IP's first three octets>.1
dns-nameservers 8.8.8.8 8.8.4.4

#iface ens3 inet6 dhcp #does not seem to work for OVH VPS 2016 range

#--static IPv6--
iface ens3 inet6 static
address <IPv6 address-should begin with 2001:41d0:>
netmask 128
post-up /sbin/ip -6 route add <IPv6 link local-should begin with fe80::> dev ens3
post-up /sbin/ip -6 route add default via <IPv6 link local-should begin with fe80::> dev ens3
pre-down /sbin/ip -6 route del default via <IPv6 link local-should begin with fe80::> dev ens3
pre-down /sbin/ip -6 route del <IPv6 link local-should begin with fe80::> dev ens3
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844

#--failover IP address #1--
auto ens3:0
iface ens3:0 inet static
address <failover IP address #1>
netmask 255.255.255.255
broadcast <failover IP address #1>

#--failover IP address #2--
auto ens3:1
iface ens3:1 inet static
address <failover IP address #2>
netmask 255.255.255.255
broadcast <failover IP address #2>

关于linux - 如何在 Ubuntu 16.04 上的 OVH VPS 中将 DHCP 接口(interface)更改为静态接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39849824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com