Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

FreeBSD路由设置的奇怪问题

华为云上一台12.1-RELEASE-p3 服务器, 开机后查看路由表

netstat -rn

Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.0.231      UGS      vtnet0
127.0.0.1          link#2             UH          lo0
192.168.0.0/24     link#1             U        vtnet0
192.168.0.26       link#1             UHS         lo0

接下来, ping微信支付的服务器

ping api.mch.weixin.qq.com
PING forwardtmp.weixin.qq.com (14.215.140.116): 56 data bytes
64 bytes from 14.215.140.116: icmp_seq=0 ttl=45 time=44.335 ms
64 bytes from 14.215.140.116: icmp_seq=1 ttl=45 time=44.061 ms
64 bytes from 14.215.140.116: icmp_seq=2 ttl=45 time=44.127 ms
64 bytes from 14.215.140.116: icmp_seq=3 ttl=45 time=44.026 ms
64 bytes from 14.215.140.116: icmp_seq=4 ttl=45 time=44.175 ms
64 bytes from 14.215.140.116: icmp_seq=5 ttl=45 time=44.075 ms
64 bytes from 14.215.140.116: icmp_seq=6 ttl=45 time=44.716 ms
64 bytes from 14.215.140.116: icmp_seq=7 ttl=45 time=44.082 ms
64 bytes from 14.215.140.116: icmp_seq=8 ttl=45 time=44.092 ms
64 bytes from 14.215.140.116: icmp_seq=9 ttl=45 time=44.141 ms
^C
--- forwardtmp.weixin.qq.com ping statistics ---
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 44.026/44.183/44.716/0.195 ms

这时候再看路由表

netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.0.231      UGS      vtnet0
121.51.50.140      192.168.0.1        UGHD     vtnet0
127.0.0.1          link#2             UH          lo0
192.168.0.0/24     link#1             U        vtnet0
192.168.0.26       link#1             UHS         lo0

莫名其妙的多了一条

121.51.50.140      192.168.0.1        UGHD     vtnet0

请问这是什么原因?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

提了工单后,终于解决了.
原来缺省网关必须是192.168.0.1, 而我之前设置为192.168.0.231.
为了上网,在VPC网络的路由表里,设置一条默认路由,指向配置了SNAT的服务器,就不会出现问题了.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...