Open TCP ports on Raspbian - raspberry-pi

I am trying to use my raspberry pi as a server, I have a java app using tcp port 1777 and mysql on 3306, however neither one or the other is accessible from lan (both works fine from the pi itself). When I scan the ports open on the pi from my laptop I only see the ssh and vnc ports, but when running the netstat on the pi both ports appear to be in listening state. I am running the latest version of raspbian (image had a ssh and vnc disabled by default, I enabled it in pi configuration (raspi-config)). Any ideas?

In my opinion, check which interface these services are listening on because the services listening on localhost are not 'binded' to the external network so try to make them listening on 192.**** ip address.
Example : Edit MySQL configuration
By default, MySQL is not configured to accept remote connections. You can enable remote connections by modifying the configuration file:
sudo nano /etc/mysql/my.cnf
and set bind-address = 192.** or bind-address = 0.0.0.0 then restart mysql servic:
sudo service mysql restart

Related

Having problem in connecting to remote MongoDB Server

I tried to connect a remote MongoDB Server running on Ubuntu using MongoDB Compass on Windows. But I have problems connecting always as the IP of the Windows machine changes every day.
I did the following things to connect to the remote server-
Got the IP of the Client Machine, then allowed that IP on the firewall of the server machine on port 27017.
sudo ufw allow from client_machine_ip to any port 27017
Note: The ufw status looked okay.
Got the IP of the Server Machine, then on the MongoDB configuration file on the server, I modified the bindIp.
bindIp: 127.0.0.1,server_machine_ip
Note: I restarted mongod and it was okay too.
I was able to connect the remote MongoDB Server using MongoDB Compass successfully for the first time. Then I saw, the IP of the client machine was changing every day. So, every time, the client IP changes, I need to allow that IP on the firewall of the server machine (in which I am using the MongoDB Server) on port 27017. Could you help to solve this? Thanks in advance.
You can update the firewall for port 27017 to allow from anywhere since client machine IP is not static.
sudo ufw allow 27017 #(this will allow from any IP)

How to access Mongodb in AWS EC2 Ubuntu from my laptop [duplicate]

I've successfully installed MongoDB on Windows (on a local machine) as a service, but now I want to move MongoDb to a separate server. So I extracted the tarball to a virtual server on network (running linux).
When I connected to the server ("testmongoserver") using PuTTY from my local machine, I started the mongod server and it told me that it was listening to the default 28017 port. The mongo console is also working and allowed me to create a new database (testdb) and add users to it.
However, I could not access the server from remote. When I type testmongoserver:28017 it doesn't open the HTTP console as localhost:28017 on my local machine does. I also can't connect using official drivers and providing a connectionstring.
What are the neccesarry steps to install MongoDB on Linux, so that I could access it from a remote machine with a connectionstring and use its HTTP console via testmongoserver:28017
Thanks!
1. Bind IP option
Bind IP is a MongoDB option that restricts connections to specifics IPs.
Have a look at your mongod configuration file, most of the time bind_ip is set to 127.0.0.1 for obvious security reasons. You can:
Add your desired IP by concatenating a list of comma separated values to bind MongoDB to multiple IP addresses.
Remove or comment (with # character) the bind_ip line. But be aware that all remote connection will be able to connect your MongoDB server!
More about bind_ip configuration option: https://docs.mongodb.com/manual/reference/configuration-options/#net.bindIp
Bind IP can also be set as a command argument: http://docs.mongodb.org/manual/reference/program/mongod/#cmdoption--bind_ip
2. Firewall
Check that you are not running behind a firewall
Make sure in your /etc/mongodb.conf file you have the following line,
bind_ip = 0.0.0.0
http://jitu-blog.blogspot.com.br/2013/06/allow-mongo-to-connect-from-remote-ip.html
Run netstat -a on mongo server and check a port.
Check DNS settings and check that linux server allows external connections.
Check that mongodb can accept external/remote connection.
Default port for mongo is 27017.
28017 - port for webstats.
See http://www.mongodb.org/display/DOCS/Security+and+Authentication#SecurityandAuthentication-Ports
Just had this issue and this fixed it:
Edit /etc/mongod.conf with sudo nano /etc/mongod.conf ensure that the net section looks like below (localhost binding by default doesn't allow for remote access):
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
Make sure to restart mongod when you are done with above with below (assuming systemd ubuntu 16.04+ etc.):
sudo service mongod restart
Obviously from a security perspective if you are going to be opening up mongo to your network/the world be aware of the implications of this (if any)
Another problem may be that the mongodb port is not enabled. Check, from another host, the ports enabled on your server. For that you can use the command:
sudo nmap -P0 your_server_ip
You can get an answer like this:
Host is up (0.052s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp closed https
If you use a virtual server in the cloud, as AWS, you need to add a new rule to add mongodb port (27017 by default).
Important: Note that with this configuration anyone can have access to your database
I fixed by below reference :
https://medium.com/founding-ithaka/setting-up-and-connecting-to-a-remote-mongodb-database-5df754a4da89
Actually, first i changed my bindIp from 127.0.0.1 to 0.0.0.0 in mongod.conf,
and enable security:
security:
authorization: "enabled"
then i restarted mongod using sudo service mongod restart.(because of new changes in mongod.conf), after that set firewall to open mongod running port (by iptables) and create a new user in admin db with new access (based on this link : https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac), finally test open ports in my server from outside with (https://www.yougetsignal.com/tools/open-ports/) and connected successfully to remote mongod using mongocompass.exe.

vsftpd installation on ubuntu 16.04 LTS

I'm use Linux server with vsftpd connection created successfully but i can't retrieve the files
Your screenshot shows that the connection timed out when trying to transfer something (LIST) after switching to Passive Mode (PASV). In my opinion, probably your firewall is not correctly configured for Passive Mode and therefore is blocking the connection.
Try allowing incoming (inbound) connections on port 40000 to 50000 for all IP address or the IP address of your FTP client. Configuring firewall is firewall-specific, therefore, I cannot give you detailed instruction on how to do this.
sudo ufw allow 40000:50000/tcp
sudo service vsftpd restart

How to ping to my local machine from AWS EC2 instance?

I have started an ubuntu instance on AWS EC2
e.g. [ec2-user#ip-XXX-XX-XX-XX ~]$
Inside this instance, I am running a socket program for sending the data to my local system.
The program is running properly, but not able to connect to my local IP.
I am trying to ping my local system also from AWS ec2 user, but it is also not working.But I am able to ping google(8.8.8.8).
e.g. [ec2-user#ip-xxx-xx-xx-xx ~]$ ping xxx.xxx.xx.xx(my local IP)
I have set all security groups(inbound), like All Trafic,All TCP and so on.
Sorry for bad English.
Thank You
Your computer (PC) cannot be pinged from an AWS hosted machine
This is probably because the VM on your computer is using NAT outbound to talk to the LAN, which goes to an Internet router, which sends the packets to AWS
The reverse route (inbound to your PC) does not exist so starting a ping echo request from a AWS machine will not work
It is possible to get around this by opening a pass through on your router but generally this is not a great idea
However if you want to make a socket connection securely there is a way
First, start a ssh session with remote port forwarding. In the Linux ssh client this is using the -R option.
For example, if your local system is running a listening service on port 80 and your remote system has the address of 54.10.10.10 then
ssh -R 8080:localhost:80 ec2-user#54.10.10.10
Will establish a circuit such that connections to the "localhost" on the remote ec2 server on port 8080 are connected to the "localhost" on port 80 of your local machine
If you are not using a ssh cli program, most ssh clients have a facility of this sort.
Note that it is necessary to keep the ssh session open to be able to use the connections

Opening port so that pgAdmin on Windows 7 can connect to PostgreSQL on Debian on VirtualBox

Hello all :) I'm a having a little trouble connecting this.
On Windows 7 about my Debian 6 on VitualBox configured with Host-only Adapter:
>nmap -T4 -A -v 192.168.56.1
[...]
5432/tcp unknown postgresql
On the Debian, PostgreSQl is listening:
>netstat -tulpn
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 2432/postgres
tcp6 0 0 :::5432 :::* LISTEN 2432/postgres
.. and the port is opened
>iptables -nL
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0./0 tcp dpt:5432
.. and Postgres is accepting all the connections in postgresql.conf
listen-addresses = '*'
port = 5432
In Windows I have this error message from pdAdmin:
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "192.168.56.1" and accepting TCP/IP
connections on port 5432?
If you encounter this message, please check if the server you're trying
to contact is actually running PostgreSQL on the given port.
Test if you have network connectivity from your client to the server
host using ping or equivalent tools. Is your network / VPN / SSH tunnel /
firewall configured correctly?
For security reasons, PostgreSQL does not listen on all available
IP addresses on the server machine initially. In order to access
the server over the network, you need to enable listening on the
address first.
For PostgreSQL servers starting with version 8.0, this is controlled
using the "listen_addresses" parameter in the postgresql.conf file.
Here, you can enter a list of IP addresses the server should listen
on, or simply use '*' to listen on all available IP addresses. For
earlier servers (Version 7.3 or 7.4), you'll need to set the
"tcpip_socket" parameter to 'true'.
You can use the postgresql.conf editor that is built into pgAdmin III
to edit the postgresql.conf configuration file. After changing this
file, you need to restart the server process to make the setting effective.
If you double-checked your configuration but still get this error
message, it's still unlikely that you encounter a fatal PostgreSQL
misbehaviour. You probably have some low level network connectivity
problems (e.g. firewall configuration). Please check this thoroughly
before reporting a bug to the PostgreSQL community.
Best regards
What about your pg_hba.conf file?
Have you configured it to accept connections from hosts in the 192.168.56.0 network?
Try to add this line and restart Postgres:
# VitualBox Host-Only Adapter
host all all 192.168.56.0/24 md5
If it's a testing environment you could even replace 192.168.56.0/24 with 0.0.0.0/0 and forget about it.