我在 Amazon EC2 服务器上运行 Ubuntu。我有一个公共 IP 地址 ( 52.38.20.76
)。
我无法将公共 IP 地址绑定到 UDP 端口:
udp listen 52.38.20.76:3478: Cannot assign requested address
Run Code Online (Sandbox Code Playgroud)
因此,我试图更改 ifconfig 以显示公共 IP 地址而不是私有 IP 地址。但是,我尝试过的网络更改没有奏效。
编辑 /etc/network/interfaces.d/eth0.cfg
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 52.38.20.76
netmask 255.255.255.0
gateway 172.31.32.1
dns-nameservers 8.8.8.8 8.8.4.4
Run Code Online (Sandbox Code Playgroud)
网关,我基于一个route -n
命令的结果:
目标网关 Genmask Flags Metric Ref Use Iface 0.0.0.0 172.31.32.1 0.0.0.0 UG 0 0 0 eth0 172.31.32.0 0.0.0.0 255.255.240.0 U 0 0 …