大网数据广告活动
服务器运维问答

Can't use external IP on Hetzner VPS

· 52CE 我爱测

I've changed my virtual server model on Hetzner recently. The new one has an external IPv4 address on which it's accessible from the internet (as it should). But I can't use this external IP in configuration: iptables rules have …

问题原文

原帖链接 · bakatrouble · CC BY-SA 3.0

I've changed my virtual server model on Hetzner recently. The new one has an external IPv4 address on which it's accessible from the internet (as it should). But I can't use this external IP in configuration: iptables rules have no effect, openvpn server can't bind a listener on any port using this IP etc. I've found a 'local' IP address (172.31.x.x) in ifconfig output, and if I use it in configuration, everything works like a charm.

On my old server I've been able to use it anywhere. So I'm just wondering: why could external IP don't work for my new server? OS is Ubuntu 15.04

已采纳解答

原帖链接 · kasperd · CC BY-SA 4.0

Hetzner had stopped assigning public IPv4 addresses to virtual servers. As far as I can tell this change happened when they changed the product name from VQ to CX. The usage of NAT is not mentioned in the product description though.

Eventually Hetzner introduced a newer cloud platform in which VMs get real public IPv4 addresses and a routed /64 IPv6 prefix. Both versions share the CX name.

Virtual servers ordered in 2012 and 2013 would keep their public IPv4 address until 2019 when the VQ line was discontinued. But virtual servers ordered in 2016 only have an RFC1918 address, and Hetzner will not route a public IPv4 address to such a virtual server.

They still allocated a dedicated public IPv4 address to each virtual server, which they NAT to the assigned RFC1918 address. Hetzner believed this was not a problem because it was a 1:1 NAT.

As you found out, this is error prone when configuring the server. You have to know about this NAT. And you have to look up the mapping whenever you configure something. For the first virtual server we got in such a configuration it got misconfigured twice in the first couple of days due to this.

Any software which relies on knowing the public IPv4 address will either break or need special configuration. Additionally some VPN and IP-tunnel can have problems because tunneled packets won't be NATed.

If you have established that these potential problems do not affect your intended usage, and if you are comfortable with having to take the mapping between public and private addresses into account when making configuration changes, you can accept the situation.

However be aware that most NAT implementations are stateful. If the NAT is indeed stateful, you may experience TCP connections stalling when state is lost.

I do not know whether the NAT used by Hetzner is stateful or stateless. The most obvious way I could think of testing for statefulness is to tunnel connection establishment and disable the tunnel once a TCP connection is established. Alas this kind of tunneling is exactly what won't work, so in order to perform this experiment one would have to replicate their 1:1 NAT configuration first. I did not attempt this rather complicated experiment.

These are the options you have:

  • Upgrade to the newer CX line on which Hetzner will give you a real IPv4 address and a routed /64 IPv6 prefix.
  • Accept that your traffic will go through a 1:1 NAT with the drawbacks that introduces.
  • Do all your important traffic on IPv6 - as Hetzner do route IPv6 traffic properly with no NAT.
  • Switch to a dedicated server (assuming those still get a public IPv4 address, which is hard to figure out since the usage of NAT is not mentioned anywhere in the product description).
  • Switch to a different provider.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-09-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。