我刚进入Linux,我需要你的帮助,我的ovh vps ubuntu服务器16.04lts接口实际上在dhcp上是静态的
实际上,我的/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,我需要把它转换成一个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)
我该怎么做?
最佳答案
下面是一个示例文件,其中包含来自我的一台服务器的指南:
请注意:并非所有ovh服务器都支持ipv6或路由ipv6地址。您可以在控制面板中选中此项,如果您没有看到要使用的地址或不希望IPv6支持不包括该部分。
要查找路由IPv6所需的链接本地地址,可以通过OVH API或converting the interface's MAC address into an appropriate link-local address.找到。
当然,如果您没有任何故障转移IP地址,请不要包含该部分。
最后,请注意,在一些基于vmware的vm上,网关的最后八位字节可能需要.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)更改为STATIC接口(interface),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39849824/