Showing posts with label telnet. Show all posts
Showing posts with label telnet. Show all posts

 How to check if a remote server port is open or not

                                      by Jephe Wu - http://linuxtechres.blogspot.com


Objective: test from a Linux client to decide if remote server port is open or not

Method 1:  telnet

e.g. telnet server1 389  - check if tcp/389 is open on server1 to client


Method 2: nc 

e.g. nc -vz server1 389  - check if tcp/389 is open on server1 to client

or nc -w 5 -vz server1 389 to specify timeout value


Method 3: openssl

Sometimes, there's no telnet or nc available/installed on client, we can try openssl

e.g.  openssl s_client -connect server1:389

 

Method 4: curl 

server 1 has ip 1.2.3.4


[root@server1 unixadm]# curl -v  telnet://1.2.3.4:10002
* About to connect() to 1.2.3.4 port 10002 (#0)
*   Trying 1.2.3.4...
* Connected to 1.2.3.4 (1.2.3.4) port 10002 (#0)

Method 5: from Windows Powershell

PS c:\users\jwu> Test-NetConnection -computername xxxx -port 443


Method 6: Linux bash shell

(timeout 1 bash -c "</dev/tcp/x.x.x.x/8080" && echo -n PORT OPEN || echo -n PORT CLOSED)


How to troubleshoot Internet connectivity issues

Jephe Wu - http://linuxtechres.blogspot.com

Situation: packet loss on Internet between countries, one end ip is 1.2.3.4, other end is 5.6.7.8
Objective: use free tools to troubleshoot the issue


Tools:
1. ping
ping -c 100 1.2.3.4 to check the RTT and packet loss rate

2. traceroute or tracert

check the RTT time for each hop.

You can paste the result to http://www.geobytes.com/TraceRouteLocator.htm to get the location information.

3. tcptraceroute or traceroute -T(CentOS 5)

If the udp normal traceroute is not able to go through, you can try tcptraceroute or traceroute -T

4. telnet or nc

telnet serverip portnumber to check the connectivity

nc -vz servername portnumber to check if tcp portnumber is open,


nc -zv jephe01 22
Connection to jephe01 22 port [tcp/ssh] succeeded!




nc -zuv time.windows.com 123
Connection to time.windows.com 123 port [udp/ntp] succeeded!


5. mtr (My TraceRoute) - http://www.bitwizard.nl/mtr/

use mtr to check packet loss and RTT time.

6. wireshark(GUI) or tshark(CLI)

use tshark to monitor packet loss (tcp retransmission)

7. tcpdump to check if the traffic is coming into the server

References:
http://www.geobytes.com/IpLocator.htm  - IP Locator