我有一个运行 Ubuntu 的 vps,它有两个网络接口。
这是是否配置启用第二个网络接口后的输出:
ens32 Link encap:Ethernet HWaddr 00:50:56:a8:36:67
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fea8:3667/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1883513 errors:0 dropped:280 overruns:0 frame:0
TX packets:362667 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251522994 (251.5 MB) TX bytes:72543049 (72.5 MB)
ens34 Link encap:Ethernet HWaddr 00:50:56:9b:65:a0
inet addr:10.20.96.88 Bcast:10.20.97.255 Mask:255.255.254.0
inet6 addr: fe80::250:56ff:fe9b:65a0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:281993 errors:0 dropped:85 overruns:0 frame:0
TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18905402 (18.9 MB) TX bytes:4380 (4.3 KB)
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:172 errors:0 dropped:0 overruns:0 frame:0
TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:12848 (12.8 KB) TX bytes:12848 (12.8 KB)
我在端口 9601 上有一个服务器绑定,可以通过http://192.168.1.20:9601, 然而http://10.20.96.88:9601无法访问。
路由输出:
default via 192.168.1.1 dev ens32 onlink
10.20.96.0/23 dev ens34 proto kernel scope link src 10.20.96.88
192.168.1.0/24 dev ens32 proto kernel scope link src 192.168.1.20
ufw 状态输出:
Status: inactive
ping 10.20.96.88输出:
PING 10.20.96.88 (10.20.96.88) 56(84) bytes of data.
64 bytes from 10.20.96.88: icmp_seq=1 ttl=64 time=0.047 ms
64 bytes from 10.20.96.88: icmp_seq=2 ttl=64 time=0.044 ms
64 bytes from 10.20.96.88: icmp_seq=3 ttl=64 time=0.052 ms
64 bytes from 10.20.96.88: icmp_seq=4 ttl=64 time=0.062 ms
64 bytes from 10.20.96.88: icmp_seq=5 ttl=64 time=0.052 ms
64 bytes from 10.20.96.88: icmp_seq=6 ttl=64 time=0.061 ms
64 bytes from 10.20.96.88: icmp_seq=7 ttl=64 time=0.051 ms
64 bytes from 10.20.96.88: icmp_seq=8 ttl=64 time=0.053 ms
64 bytes from 10.20.96.88: icmp_seq=9 ttl=64 time=0.048 ms
答案1
如果你想使用这个 IP 作为专用 IP 来与某个特定服务器通信,你也许应该定义静态路由。