Test connectivity for the web service: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
find the problem occurred: (1) local service at the server (localhost) (2) from LAN to server (3) from WAN to server
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 local web service ===
After logged into the server
If the service is the web server:
* (1) Open the browser, (2) Type the address: {{kbd | key = <nowiki>http://127.0.0.1</nowiki> }}
* Linux command:
*# (optional if lynx was not installed) {{kbd | key = <nowiki>yum install lynx</nowiki>}} for CentOS / {{kbd | key = <nowiki>sudo apt-get install lynx</nowiki>}} for Ubuntu<ref>[http://www.addictivetips.com/ubuntu-linux-tips/install-and-use-lynx-on-ubuntu/ Install and Use Lynx Browser on Ubuntu]</ref>
*# {{kbd | key = <nowiki>lynx http://127.0.0.1</nowiki>}} <ref>[http://lynx.isc.org/lynx2.8.7/lynx2-8-7/lynx_help/Lynx_users_guide.html Lynx Users Guide v2.8.7]</ref> for {{Linux}}
If the service is not the web server, use telnet instead
# {{kbd | key = telnet 127.0.0.1 <PORT>}} e.g. {{kbd | key = telnet 127.0.0.1 80}}
# (after telnet-ed the web 80 port, key in) {{kbd_plus | key1 = get | key2 = SPACE}}
# more on [http://www.simplescripts.de/http-check-port-80-telnet-command.htm HTTP Check Port 80 with the Telnet Command]
=== How to connect to remote web service ===
Open the browser from outside network ex: Wide Area Network (WAN) or Local Area Network (LAN)
* and type the address: {{kbd | key =<nowiki>http://the.domain</nowiki>}} {{exclaim}} Note: Not [https://en.wikipedia.org/wiki/Private_network Private network] / Private IP address
* or use the remote website monitoring services: [[Web Ping]]
Using alternative web services if the Python was installed
* (for python 2.x) {{kbd | key=<nowiki>python -m SimpleHTTPServer <port></nowiki>}}<ref>[https://docs.python.org/2/library/simplehttpserver.html 20.19. SimpleHTTPServer — Simple HTTP request handler — Python 2.7.17 documentation]</ref>
* (for python 3.x) {{kbd | key=<nowiki>python -m http.server <port></nowiki>}}<ref>[https://docs.python.org/3.8/library/http.server.html?highlight=http%20server#module-http.server http.server — HTTP servers — Python 3.8.1 documentation]</ref>
Using telnet client
* (optional) [https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771275(v=ws.10) Install Telnet Client | Microsoft Docs] on {{Win}}. [https://medium.com/@blackSource/bring-telnet-back-on-macos-high-sierra-11de98de1544 Bring telnet back on macOS high Sierra – Ayuth Mangmesap (blackSource) – Medium] on {{Mac}}
* telnet ''DOMAIN_or_IP'' ''PORT'' ex: {{kbd | key = telnet the.domain 80}}
** If connected. The console windows will show the message "Escape character is '^]'. " for {{Linux}}. Or show a blank window for {{Win}} If you want to end the telnet command. You can (1) press {{Kbd plus | key1 = Ctrl | key2 = ]}} and (2) keyin {{Kbd | key = quit}} to end the telnet.
** If failed. It will show the message: "telnet: Unable to connect to remote host: Connection refused"
curl
* {{kbd | key = <nowiki>curl -v -o /dev/null http://IP:Port</nowiki>}} If failed. It will show the message: "failed: Connection refused"




Line 63: Line 95:
<span style="color:red">WAN &#9679; -------&gt; &#9679; LAN -------&gt; &#9679; server</span>
<span style="color:red">WAN &#9679; -------&gt; &#9679; LAN -------&gt; &#9679; server</span>


=== How to connect to remote web service ===
Open the browser from outside network ex: Wide Area Network (WAN) or Local Area Network (LAN)
* and type the address: {{kbd | key =<nowiki>http://the.domain</nowiki>}} {{exclaim}} Note: Not [https://en.wikipedia.org/wiki/Private_network Private network] / Private IP address
* or use the remote website monitoring services: [[Web Ping]]
Using alternative web services if the Python was installed
* (for python 2.x) {{kbd | key=<nowiki>python -m SimpleHTTPServer <port></nowiki>}}<ref>[https://docs.python.org/2/library/simplehttpserver.html 20.19. SimpleHTTPServer — Simple HTTP request handler — Python 2.7.17 documentation]</ref>
* (for python 3.x) {{kbd | key=<nowiki>python -m http.server <port></nowiki>}}<ref>[https://docs.python.org/3.8/library/http.server.html?highlight=http%20server#module-http.server http.server — HTTP servers — Python 3.8.1 documentation]</ref>
Using telnet client
* (optional) [https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771275(v=ws.10) Install Telnet Client | Microsoft Docs] on {{Win}}. [https://medium.com/@blackSource/bring-telnet-back-on-macos-high-sierra-11de98de1544 Bring telnet back on macOS high Sierra – Ayuth Mangmesap (blackSource) – Medium] on {{Mac}}
* telnet ''DOMAIN_or_IP'' ''PORT'' ex: {{kbd | key = telnet the.domain 80}}
** If connected. The console windows will show the message "Escape character is '^]'. " for {{Linux}}. Or show a blank window for {{Win}} If you want to end the telnet command. You can (1) press {{Kbd plus | key1 = Ctrl | key2 = ]}} and (2) keyin {{Kbd | key = quit}} to end the telnet.
** If failed. It will show the message: "telnet: Unable to connect to remote host: Connection refused"
curl
* {{kbd | key = <nowiki>curl -v -o /dev/null http://IP:Port</nowiki>}} If failed. It will show the message: "failed: Connection refused"
=== other issues ===
We met the trouble on WAN (wide area network). If we do no have the administrative permission, the tests we can do as follows:
We met the trouble on WAN (wide area network). If we do no have the administrative permission, the tests we can do as follows:
*  [http://downforeveryoneorjustme.com/ Down for everyone or just me?] more on [[Web_Ping#同時從世界各處測試網站連線 | Web Ping]]
*  [http://downforeveryoneorjustme.com/ Down for everyone or just me?] more on [[Web_Ping#同時從世界各處測試網站連線 | Web Ping]]

Revision as of 10:34, 25 March 2022

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 local web service

After logged into the server If the service is the web server:

  • (1) Open the browser, (2) Type the address: http://127.0.0.1
  • Linux 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

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

  1. telnet 127.0.0.1 <PORT> e.g. telnet 127.0.0.1 80
  2. (after telnet-ed the web 80 port, key in) get + SPACE
  3. more on HTTP Check Port 80 with the Telnet Command


How to connect to remote web service

Open the browser from outside network ex: Wide Area Network (WAN) or Local Area Network (LAN)

  • and type the address: http://the.domain Icon_exclaim.gif Note: Not Private network / Private IP address
  • or use the remote website monitoring services: Web Ping

Using alternative web services if the Python was installed

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

Using telnet client

curl

  • curl -v -o /dev/null http://IP:Port If failed. It will show the message: "failed: Connection refused"


Connecting from the local machine to web service at the same server

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[5]
  • Win Os windows.png : Check the IP Address. ifconfig/all
  • More on Network problem

Is the service alive or the 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[6] 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.
  • 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[7].
$ netstat -tulpn | grep LISTEN

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      - 

// means the 80 port service is running

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[8] (2) rule with smaller line-number will override the rule with larger line-number[9]
      • FirewallD rules: (1) sudo firewall-cmd --get-default-zone return 'public' (2) sudo firewall-cmd --list-all --zone=public[10] (3) Allow port with FirewallD
      • SELinux Policy Management: (1) After installed policycoreutils-python[11], 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

Connecting 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.*) may not have the firewall limit.

  • 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?

Connecting from WAN to the 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]

References


Troubleshooting of ...

Template