【原创】Linux基础之测试域名IP端口连通性

一 测试域名是否可达

1 ping

# ping www.baidu.com
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244 (220.181.112.244): icmp_seq=1 ttl=52 time=2.51 ms
64 bytes from 220.181.112.244 (220.181.112.244): icmp_seq=2 ttl=52 time=2.50 ms

2 nslookup

# nslookup www.baidu.com
Server: 103.224.222.222
Address: 103.224.222.222#53

Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 220.181.112.244

二 测试ip是否可达

1 ping

# ping 220.181.112.244
PING 220.181.112.244 (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244: icmp_seq=1 ttl=52 time=2.57 ms
64 bytes from 220.181.112.244: icmp_seq=2 ttl=52 time=2.55 ms

2 traceroute

# traceroute 220.181.112.244
traceroute to 220.181.112.244 (220.181.112.244), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 100.127.3.117 (100.127.3.117) 0.933 ms * 100.127.3.115 (100.127.3.115) 1.055 ms
4 * * *
5 100.127.125.82 (100.127.125.82) 2.489 ms 100.127.125.80 (100.127.125.80) 2.475 ms 100.127.125.18 (100.127.125.18) 2.519 ms
6 180.149.137.117 (180.149.137.117) 7.877 ms 180.149.137.145 (180.149.137.145) 3.965 ms 100.127.125.10 (100.127.125.10) 2.341 ms
7 180.149.159.77 (180.149.159.77) 2.347 ms 180.149.159.57 (180.149.159.57) 2.456 ms 180.149.159.17 (180.149.159.17) 3.372 ms
8 * 36.110.246.201 (36.110.246.201) 7.804 ms 180.149.159.17 (180.149.159.17) 2.341 ms
9 * 220.181.0.109 (220.181.0.109) 2.997 ms 36.110.246.205 (36.110.246.205) 2.756 ms
10 * 220.181.17.94 (220.181.17.94) 2.962 ms 220.181.17.22 (220.181.17.22) 2.767 ms
11 * * 220.181.17.150 (220.181.17.150) 2.559 ms
12 * * *
13 * * *
14 * * *

三 测试端口是否可达

1 telnet

# telnet 220.181.112.244 80
Trying 220.181.112.244...
Connected to 220.181.112.244.
Escape character is '^]'.

2 nc

# nc 220.181.112.244 80 -v
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 220.181.112.244:80.

3 curl

# curl http://220.181.112.244:80 -v
* Trying 220.181.112.244...
* TCP_NODELAY set
* Connected to 220.181.112.244 (220.181.112.244) port 80 (#0)
> GET / HTTP/1.1
> Host: 220.181.112.244
> User-Agent: curl/7.63.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: Keep-Alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Sat, 16 Feb 2019 02:35:56 GMT
< Etag: "588604c8-94d"
< Last-Modified: Mon, 23 Jan 2017 13:27:36 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
<
<!DOCTYPE html>

猜你喜欢

转载自www.cnblogs.com/barneywill/p/10386968.html