12/21 更新:用了半年的 Vultr 后回来补充一下。这篇文章上遇到的问题只在我开的第一个实例上遇到过,按照文中的方法自然是连上了,但是每次重启后你编辑过的那个配置文件都会被重置,非常不方便。后来因迁移机房需要,重新开了一个实例,经常重启过甚至还更新过系统,至今没有再遇到过ssh不上的问题。所以作为补充,我认为ssh不上的原因可能有两个:1、自己操作失误(主要针对海外也完全ping不通的情况),那么按照本文的方法试试,不过还是建议修复你操作失误的地方,如果无法修复那就重开instance吧;2、你的instance被墙啦,原因不用多说吧?那个IP已经废掉了。

另补充后来弄清楚了,文末提及的IP保留费用仅在IP闲置没有绑定实例时收取,如果保留了IP尽快将其绑定到新实例上就停止计费啦。

建议阅读完全文再决定下一步的操作


今天设置WordPress的STMP发件功能,发现我的主机商Vultr,默认禁止了STMP的25,465和587端口,于是开ticket找客服,客服倒是很快告诉我已经帮我解禁了,重启服务器即可。立即重启,这时发现PuTTY连不上服务器,站长之家测试Ping全部节点超时,只能通过Vultr网站上提供的Console查看服务器,于是在服务器上ping Google.com, 返回Bad Timing Internal,就是说服务器完全断网。

赶快Google,发现英文结果里面似乎没有遇到这个问题的,反倒是v2ex上面看到一个帖子在讨论,基本看下来都怀疑和GFW有关,这一点我不清楚,我单纯重启才出现的问题,感觉更像是Vultr自己的bug。

找了一阵,无果,于是又开一个ticket问Vultr技术组(之前那个解禁端口的是Account Managemment Team负责)。基本情况告诉他,很快给我了回复:

Hello,

May I rebuild your instance's internal network configuration? This will cause your instance to reboot.

Thanks,

Joshua Brand
Systems Administrator

回复他可以,过了十多分钟回复我:

I have rebuilt your network configuration, however, I am unable to ping or SSH to your VPS. Please try restarting your VPS via the console. If issues still persist, please set your VPS to use a static configuration. See below:

Please try setting your OS's network interface configuration for static IP assignments in this case. The blue "network configuration examples" link on the "Settings" tab includes the necessary file paths and configurations. This configuration change can be made via the provided web console.

Setting your instance's IP to static will prevent any issues that your chosen OS might have with DHCP lease failure. Any instance with additional IPs or private networking enabled will require static addresses on all interfaces as well.

If you find you are still having problems & cannot connect, please let us know. We will request an MTR to & from your server(s) if you are able to generate them. This will allow us to determine if this is something we are able to fix or if it is a larger problem (e.g. issues with the great firewall in China, censorship issues, blocking at the BGP level, etc).

注意这里有提及GFW,我之后问过他GFW有何影响他没有回复这个问题。于是按照他说的做了,那个network configuration链接里面的内容大致如下:

Location:London
Main IP Address:45.xx.xxx.xx

Important Information

  • In most cases, you should not need to adjust these files. Instances are normally configured using DHCP. You only really need to change these files if you are trying to enable additional IPs.
  • Changing to the examples below will cause problems if you take a snapshot of an instance and restore it. We recommend reverting back to DHCP before taking a snapshot.
  • You must restart your server via the control panel after adding extra IPs.

Ubuntu 16.xx, Ubuntu 17.04

/etc/network/interfaces

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
    address 45.xx.xxx.xx
    netmask 255.xxx.xxx.x
    gateway 45.xx.xxx.x
    dns-nameservers 108.xx.xx.xx
    post-up ip route add 169.xxx.x.x/16 dev ens3

后面的就是其他各种系统相应的代码了(IP部分安全起见我已经换成了x)。这一步我的实际操作是:

$ sudo nano /etc/network/interfaces

进入nano编辑器后把文件内原有内容全部删除,换成上面红字部分的内容(我的操作系统是Ubuntu16.04),这里注意Vultr的console全屏支持不太好,底下的菜单要手动拖侧面的滚动条才能看到。之后在root账户下使用shutdown -r now命令重启(这里很重要,千万不要再用Vultr面板里面那个重启按键了,那是Force to reboot,然后命令行里面重启也需要用root账户,否则开机可能会遇到权限问题

重启之后SSH远程顺利连上了。事情至此已经解决,不过接下来我随意问了一下静态IP是否改变我的Instance费用,没想到看到了这样的回复:

Changing to a static configuration will not affect the instance's charge; however, note that this address is not reserved. If you want to convert this address or create a new reserved address, go to https://my.vultr.com/ips/ and select the 'Add New Reserved IP' button.

我赶快问他:“What does "address is not reserved" mean? What will happen if I do not reserve address? For my current IP 45.xx.xxx.xx, may I use it as my server's IP as long as I keep this instance?”

回复道:

If you need to destroy your instance but keep your IP address, then you would set your IP as a reserved IP address. If you are not going to destroy your instance, but re-install the OS, then you do not need a reserved IP.

懒得再问了,因为他回复实在太慢。这个Reserve IP的服务反正是3美元一个月,我的服务器也就5美元一个月,当然是不会开的,他的最后两句话我也不是太明白,猜想大约不会对使用中的服务器IP有影响,而这里只是想挖个坑诱导我去消费。以上就是我解决服务器无法通过公网IP进行远程SSH连接的解决过程,有没有什么副作用暂时还不清楚,不过目前服务器各项服务正常,应该没什么问题了吧,以后避免重启,多备份,避免这些麻烦。

虽然最后一个问题没太跟我说清楚,并且这多半也是Vultr自己的bug,不过Vultr的服务态度总体还是不错的,很感谢这个客服,其实挺耐心的。

本文仅提供参考,遇到问题还是优先联系客服好,只是也不用太着急,至少这里是一个保底的方案。

Q.E.D.