Network test
Jump to navigation
Jump to search
dns
name server resolver from specific dns
nslookup campisano.org 8.8.4.4
network access
ping campisano.org
routing
traceroute -M tcp -N 100 -m 100 campisano.org
specific port access
telnet campisano.org 80
perl homemade telnet version
- in some basic system like cloud minimal virtual machines, there are no network utilities like telnet, so there is a simple perl implementation (using vanilla Socket package):
#!/usr/bin/env perl # from https://www.oreilly.com/openbook/webclient/ch04.html use Socket; $|=1; # autoflush sub open_TCP { # get parameters my ($FS, $dest, $port) = @_; my $proto = getprotobyname('tcp'); socket($FS, PF_INET, SOCK_STREAM, $proto); my $sin = sockaddr_in($port,inet_aton($dest)); connect($FS,$sin) || return undef; my $old_fh = select($FS); $| = 1; # don't buffer output select($old_fh); 1; } # If no parameters were given, print out help text $num_args = $#ARGV + 1; if ($num_args != 3) { print "Usage: telnet.pl <host> <port> <text>\n"; print "Example: telnet.pl www.campisano.org 80 \$'GET /wiki/en/Main HTTP/1.0\\r\\nHost: www.campisano.org\\r\\n\\r\\n'\n"; exit(-1); } $host=$ARGV[0]; $port=$ARGV[1]; $text=$ARGV[2]; # contact the server print "connecting $host:port ...\n"; if (open_TCP(F, $host, $port) == undef) { print "Error connecting to server at $ARGV[0]\n"; exit(-2); } # send the GET method with / as a parameter print "sending $text ...\n"; print F "$text"; # print out the response print "printing response ... \n"; print $_ while (<F>); close(F);