Test connectivity for the web service: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
Line 62: Line 62:
** [http://linuxcommand.org/man_pages/ps1.html ps] List the current processes. Input {{kbd | key = <nowiki>ps -aux | grep "PORT_NUMBER"</nowiki>}} e.g. {{kbd | key = <nowiki>ps -aux | grep 443</nowiki>}}
** [http://linuxcommand.org/man_pages/ps1.html ps] List the current processes. Input {{kbd | key = <nowiki>ps -aux | grep "PORT_NUMBER"</nowiki>}} e.g. {{kbd | key = <nowiki>ps -aux | grep 443</nowiki>}}
** [https://docs.oracle.com/cd/E19504-01/802-5753/6i9g71m3i/index.html netstat Command] {{kbd | key=<nowiki>netstat -tulpn | grep LISTEN</nowiki>}} e.g.  
** [https://docs.oracle.com/cd/E19504-01/802-5753/6i9g71m3i/index.html netstat Command] {{kbd | key=<nowiki>netstat -tulpn | grep LISTEN</nowiki>}} e.g.  
** [https://docs.docker.com/engine/reference/commandline/port/ docker port | Docker Documentation]


Example output of netstat command
Example output of netstat command

Revision as of 16:56, 30 January 2023

find the problem occurred: (1) local service at the server (localhost) (2) from LAN to server (3) from WAN to server

How to connect to the web service

If the service is the web server:

  • (1) Open the browser, (2) Type the address: http://127.0.0.1 or http://the.domain
  • Linux lynx command:
    1. (optional if lynx was not installed) yum install lynx for CentOS / sudo apt-get install lynx for Ubuntu[1]
    2. lynx http://127.0.0.1 [2] for Linux Os linux.png
  • telnet command
    1. telnet 127.0.0.1 <PORT> e.g. telnet 127.0.0.1 80 or telnet the.domain 80
    2. (after telnet-ed the web 80 port, key in) get + SPACE[3]
  • curl[4]: curl -vL http://IP:Port
    • (optional if curl command was not installed) Learn how to install & run cURL on Windows/MacOSX/Linux | Ubidots Help Center
    • commands e.g.
      • (1) Write output to <file> instead of stdout using curl -voL https://www.google.com
      • (2) Write output to stdout using curl -vL https://www.google.com or curl -voL /dev/null https://www.google.com
      • (3) Write output to <file> with the remote file name using curl -vOL https://www.google.com/index.html
    • If failed. It will show the message: "failed: Connection refused"
  • Linux wget software e.g. wget https://www.google.com
  • use the third-party website monitoring the services: Web Ping

If the service is not the web server, use telnet instead

  1. (optional) Install Telnet Client | Microsoft Docs on Win Os windows.png . Bring telnet back on macOS high Sierra – Ayuth Mangmesap (blackSource) – Medium on Mac icon_os_mac.png
  2. telnet 127.0.0.1 <PORT> If failed to connect the web service. It will show the message: "telnet: Unable to connect to remote host: Connection refused"

Using alternative web services if the Python was installed

  • (for python 2.x) python -m SimpleHTTPServer <port>[5]
  • (for python 3.x) python -m http.server <port>[6]

Test connectivity for the local web service

WAN ○ -------> ○ LAN -------> ● server

Owl icon.jpg If you has administrative permission to log into the server via SSH or Remote desktop service.

Check if your computer/server Is being assigned the IP Address

  • Linux Os linux.png : (1) Check the IP Address. ifconfig. (2) Re-assign the IP Address and restart the networking service. service network restart for CentOS[7]
  • Win Os windows.png : Check the IP Address. ifconfig/all
  • More on Network problem

Is the web service alive

  • Apache /etc/init.d/httpd status on CentOS7 [8]
  • nginx sudo service nginx status on CentOS7
  • Docker container docker ps to check if the container is running & expose the port[9]

Check if a port was occupied by other process?

Check the port if used by other protocol

Find process running on port

  • Linux Os linux.png
    • nmap "Network exploration tool and security / port scanner." e.g. nmap -p 80,443 ip
    • ss "utility to investigate sockets" e.g. ss -tnlp | grep 80 or using OR operator[10] ss -tnlp | grep '80\|443'
    • ps List the current processes. Input ps -aux | grep "PORT_NUMBER" e.g. ps -aux | grep 443
    • netstat Command netstat -tulpn | grep LISTEN e.g.
    • docker port | Docker Documentation

Example output of netstat command

$ netstat -tulpn | grep LISTEN

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      - 

// means the 80 port service is running
  • Win Os windows.png
    • Using the software CurrPorts to check the process and port. e.g. Apache will not running if the 80 port was occupied by skype[11].

Check if a port is blocked by browser

Check if a port is blocked by browser[12]


Is the port opened for external users?

Check the OS firewall or protected by antivirus software

    • Linux Os linux.png
      • iptables: (1) iptables -L to list all rules[13] (2) rule with smaller line-number will override the rule with larger line-number[14]
      • FirewallD rules: (1) sudo firewall-cmd --get-default-zone return 'public' (2) sudo firewall-cmd --list-all --zone=public[15] (3) Allow port with FirewallD
      • SELinux Policy Management: (1) After installed policycoreutils-python[16], input semanage port -l to list open ports. (2) Allow port with semanage.
    • Win Os windows.png Windows Firewall with Advanced Security -> configure firewall rules
    • protected by antivirus software?
  • connect to localhost ex: telnet 127.0.0.1 23 where 23 is the port number where the service running
    • Install Telnet Client on Win Os windows.png
    • if the local service is web server, you can also try lynx http://127.0.0.1 for Linux Os linux.png
  • double check the server/service logs

Test connectivity from LAN to the server

WAN ○ -------> ● LAN -------> ● server

Testing on LAN (local network, subnet scope): The different servers between LAN or with the same ip class (ex: 1.2.3.*) and may not have the firewall limit. Private network / Private IP address

  • Is the service alive?
  • Connect to the internal IP eg: telnet 172.18.0.1 23 (1) IP start with 172.18... is Private IP Network Numbers (2) where 23 is the port number where the service running
  • If the local service is web server, you can also try to connect the internal IP e.g. lynx http://172.18.0.1 for Linux Os linux.png
  • Double check the server/service logs
  • Is the internal IP correct?

Test connectivity from WAN to the remote server

WAN ● -------> ● LAN -------> ● server

We met the trouble on WAN (wide area network). If we do no have the administrative permission, the tests we can do as follows:

other issue:

Tools

  1. Good.gif CurrPorts: Monitoring TCP/IP network connections on Windows
  2. PFPortCheck Program: check TCP/UDP port from localhost(where you installed the program) to portforward.com
  3. TCPView for Windows
  4. Check server: Check host - online website monitoring, Check IP "checks the possibility of a TCP connection to host's specified port from different locations around the world." quoted from website. [Last visited: 2015-08-02]

Related articles

References


Troubleshooting of ...

Template