“This is the sixth day of my participation in the August More Text Challenge.
In my daily work on the Intranet, it is common for the network to be disconnected. When the network is disconnected, my thoughts are as follows:
- Check whether the domain name /IP address can be pinged
- Check whether a specific port is connected
Check whether the network is normal
Application scenario: The front and back ends interact. If the front end needs to access the interface of the back end, check whether the network is normal and ping the port of the back end. If the connection fails, the firewall of the other end is enabled
ping baidu.com
Copy the code
The output is as follows:
Ping baidu.com ping baidu.com (220.181.baidu.com) 56(84) bytes of data. 64 bytes from 220.181.38.148 (220.181.38.148): Icmp_seq =1 TTL =49 time=26.6 ms 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 TTL =49 time=26.4 msCopy the code
Note that this name also yields the IP of the domain name, as shown in the figure 220.181.38.148
The above input is working. If not, it will be stuck. The output is as follows:
Ping google.com Ping google.com (93.46.8.90) 56(84) bytes of data.Copy the code
Check whether a port is normal
To ensure security, only some ports are enabled on the server. You can use Telnet ports to check whether a certain port is enabled.
telnet juejin.cn 443
Copy the code
If the port is passable, the output is as follows:
Trying 119.96.138.242...
Connected to juejin.cn.
Escape character is '^]'.
Copy the code
If no, the following output is displayed:
Telnet juejin. Cn 8080 Trying 119.96.137.241...Copy the code
Or output as follows
Telnet raasr.xfyun.cn 19999 Trying 42.62.43.138... Connected to e62acf7b4f2de86dd5dcf0748c6c8a1d.iflysec.com. Escape character is '^]'. Connection closed by foreign host.Copy the code
If the server port impassability, we can manually open ports, ports open shut down as follows: www.jianshu.com/p/b3068288d…
Perform operations as user root
Test the interface on the server
In the local environment, we have a graphical interface tool, such as postman, but the server does not have it. If you want to test the data response of an interface on the server, you can use curl command
I tested it on a random interface from the Nuggets console Network
curl https://api.juejin.cn/tag_api/v1/query_category_briefs\?
Copy the code
The output is as follows:
We can also view only the response header, using the -i parameter
curl -I https://juejin.cn/user/4388906148312295
Copy the code
The output is as follows:
HTTP/1.1 200 OK Server: Tengine Content-Type: text/ HTML; charset=utf-8 Content-Length: 579546 Connection: keep-alive Date: Thu, 05 Aug 2021 22:16:51 GMT Vary: Accept-Encoding X-Powered-By: Express x-tt-logid: 02162820181098400000000000000000000ffff0acc1a0d0a44fc ETag: "8d7da-9UN2GrglSqrBiKrteiSeSf2tylQ" Accept-Ranges: none Server-Timing: inner; dur=292, pp; dur=6, total; dur=288; desc="Nuxt Server Time" Vary: Accept-Encoding x-tt-trace-host: 011d6f0a0a05995d3b245dd3cad0158336d6085d24a5c4fca26fd5be84ed73f1ea1de42fe0d77c88616eed7e6839124294100163fa1c59f105370f1d e98c0736e8f87eeb034c540029b1136d04b9408f712fad7c9c44e7fc354672f58c1f8f0f8e x-tt-trace-tag: id=3; CDN - cache = miss Via: cache13 cn1247 [298, 0] Timing - Allow - Origin: * EagleId: 276076 a116282018109812853eCopy the code
Curl other than the most basic to get request, you can also send a post request, and to set the format of the request body data, under way for more use of this article: www.ruanyifeng.com/blog/2019/0…