Can I check if server is up without connecting to it? - bash

Is it possible to check if a remote server is up, without connecting to it?
Basically, telnet ip.ad.dre.ss port works, but will connect to the server. Is there an equivalent command, that will just check is the server is up, without establishing a connection with it?
I would like to check it in a bash script.

If your server is a remote server you can not check without connecting to the server. You can only check that by log into the Operating System where that server is running and then you have to use ps -ef | grep [p]rocessName

For a local server ss --listening will list all listening processes.
for a remote server you could connect using ssh and run ss, or test the listening socket(s) directly using nmap
`

Related

How can I connect to a remote mongodb server using the mongo shell?

Trying to connect to a remote MongoDB server I get: socket operation timed out.
and the firewall log also doesn't mention any attempted connection.
I have the Mongodb running on a remote Windows 2012 vm.
I used --bind_ip 0.0.0.0 and added the firewall rules from the docs.
pingĀ“ing from either client/server works and so does the vnc.
And I'm able to connect from the server using either localhost or the ip
Im new to networking and thought I slowly understand, but apparently thats not the case!
Is there anything else I did not consider?
Try this in your terminal
mongo -u <USER> -p <PASSWORD> <HOST>:<PORT>/<DB> --authenticationDatabase <AUTH_DB>

VNC viewer failing to make connection with "channel 3: open failed: connect failed: No route to host"

I ssh into a server with the following:
ssh -g -L5912:server:5912 user#host
It goes through, and I can access my files on the other server through the command line (meaning I can connect to the server, it is my vnc viewer that is failing!) but when I try to open my vnc viewer (RealVNC) and connect to localhost:12 i get the following error message in the vnc viewer application:
The connection closed unexpectedly.
Additionally in the original command line shell i get:
channel 3: open failed: connect failed: No route to host
I've tried switching to different ports and even checked out other posts on the same error message but the problem is i don't really understand them... ssh tunnels are still relatively new to me so i don't really know what im doing. Any help would be greatly appreciated. Thanks!
You're trying to setup a port forwarding, this may fail because of many reasons:
SSH port forwarding not enabled in the host
Check SSH server in the host if AllowTcpForwarding is enabled:
$ grep AllowTcpForwarding /etc/ssh/sshd_config
AllowTcpForwarding yes
Typically, it's commented out. Uncomment and restart the sshd.
No connection between the host and server over port 5912
SSH to the host and try:
$ telnet server 5912
Connected to server.
Escape character is '^]'.
Finally, does the server listen on 5912?
Similarly, as above, but from the server - go there and try telnet server 5912.
Best regards,
Jarek
In my case it was the port forwarding rule I had set in Putty.
Please make sure you enter the correct hostname when defining the rule in Putty. I changed
localhost:5903
with
myserver:5903
and it worked...

Rserve fails to set up connection

Up to yesterday, I have been connecting Tableau with R through Rserve on my localhost. Today, when I try to make the connection again, Tableau complained:
a error occurred during connection to localhost: 6311. No connection could be made because the target machine actively refused it
I doubled check Rserve is running. However, when I typed telnet localhost 6311 in cmd, no connection can be detected. It strikes me that something worked well for a few months suddenly stopped to function. I did installed RMySQL yesterday which seem to coincide with the timing, but is it possible? Any idea how to trouble shoot? Thanks.
Multiple things might be happening here.
check your netstat -ntlp output and see if its' listening on port 6311 and check if it's listening at 0.0.0.0:6311 or 127.0.0.1:6311. If you use the hostname rather than localhost it should be able to connect as long as the deamon is up. To connect using localhost from the same machine, stop Rserve and restart it as R CMD Rserve this will bind it to the loopback address, if you want it remotely accessible then you'll have to restart it using R CMD Rserve --RS-enable-remote
If you are using linux, you'll need to check your firewall and see if port 6311 is allowed .... ufw allow 6311 will do the trick.
Ben
This explanation may be helpful.
In my case, I was running through 'Rserve' and the configuration did not allow remote.
Initially invoke the Rserve using the command R CMD Rserve --RS-enable-remote from your server.Then call Rserve from your client machine.To test the connection try telnet IP port to the server which runs Rserve.This will do the trick.

Unable to send files using netcat

I am using netcat to send file over my campus network.
I have used
c:\nc -w200 10.x.x.x 9638 < file.txt
on my client machine and
c:\nc -v -L -p 9638 >> nc.out
on my computer that is working as a server to receive files.
It worked completely fine when i tested it using localhost hence sending and receiving files on my system only.I am using the netcat version without the GAPING_SECURITY_HOLE downloaded from http://www.rodneybeede.com/Compile_Netcat_on_Windows_using_MinGW.html.
Our systems are connected to the net using proxy servers. Could they be interfering? Also pinging computers is disabled.
I am working on windows for now.
Yes proxy and router may interfere.
Try to see if you can telnet to that port
telnet <ip> port
That will tell you if you can access that machine on that port

Amazon EC2 permissions and a simple web server

I just started experiment with EC2 tonight, and got a server running locally. I know it works locally because when I curl http://localhost:8080/hello it outputs hello.
I want to access this from the outside world. I modified my permissions in my security group to allow 8080 access, and then typed in "curl http://ec2-123-45-67-891.compute-1.amazonaws.com:8080/hello" into my local terminal. I got the response "curl: (7) couldn't connect to host".
Do I need to do something differently? (Obviously yes, but what?)
Have you bound your server only to localhost? If so, you'll only be able to connect from localhost.
Check the netstat output for your process with something like:
sudo netstat -ltnp | grep your_server_process
Look for whether your server process is bound to 127.0.0.1:8080 or 0.0.0.0:8080. If the former, then you're only bound to localhost and you need to reconfigure it.
I met the same issue. Try use 0.0.0.0 instead of 127.0.0.1.
You allowed access on 8080, but in your localhost example, it's running on port 80.

Resources