Posts: 7
fasulin
Joined: 25 Apr 2013
#1
hello all, I have mysql server installed at acccedo only console via SSH, but I can only logear within the intranet (192.168.1.x), if I try logear from home ports are closed. as I can open the ports for access from any IP? Thank you. I have antiX 12

in spanish-
hola a todos, tengo instalado un servidor mysql, al que solo acccedo via consola con SSH, pero solo puedo logear dentro de la intranet (192.168.1.x), si intento logear desde mi casa los puertos estan cerrados. como puedo abrir los puertos para acceder desde cualquier IP? gracias. tengo antiX 12
Posts: 630
Eino
Joined: 12 Oct 2012
#2
Try to execute the command" telnet your_host_name tcp_ip_port_number." (The default MySQL port number is 3306.) Then press Enter a couple of times. If you do not get an error message like telnet: Unable to connect to remote host: Connection refused, some other program is using the TCP/IP port that mysqld is trying to use. Track down what program this is and disable it, or tell mysqld to listen to a different port with the --port option. In this case, specify the same non-default port number for client programs when connecting to the server using TCP/IP.

Another reason the port might be inaccessible is that you have a firewall running that blocks connections to it. If so, modify the firewall settings to permit access to the port.

Also check your routers firewall to make sure that port 3306 is open.

If the server starts but you cannot connect to it, make sure that you have an entry in /etc/hosts that looks like this:

127.0.0.1 localhost
Posts: 1,062
Dave
Joined: 20 Jan 2010
#3
I am not really certain on the scenario you have there. to me it sounds like you have not opened the firewall on your router. with this in mind I would double check my routers firewall settings. once this has been determined, i would run nmap to determine the open ports. do this on the intranet and internet to compare. if there is an unwanted discrepancy, I would place a laptop or similar on the wan side of the router and run an nmap scan on the routers wan ip. if this works as expected your isp is blocking that kind of trafic. If the discrepancy is still there, I would powercycle the router for a bit and try again.
another possility if the laptop on wan works is your modem ( cable,fibre,DSL,etc) has a firewall configured in it. depending on the device and who supplies it this may or may not be possible.
Posts: 7
fasulin
Joined: 25 Apr 2013
#4
hi, i can access to server if i am into the intranet, but i can not connect to the server from internet (my house), iptables problem?, the router is ok, ip is DMZ and port is open ( i probe other machine with guindows is ok ). iptables problem?? sorry my poor english.

in spanish

Hola, yo puedo acceder al servidor si yo estoy dentro de la intranet, pero yo no puedo acceder desde fuera de la red (internet) desde mi casa por ejemplo, los puertos de router estan abiertos y redirigen correctamente , probe reemplazando el server por otro con guindows y funciona. creo que es problema es la IPtables y la redireccion.

thanks
Posts: 630
Eino
Joined: 12 Oct 2012

05 May 2013, 13:07 #5

Check to make sure your firewalls are not blocking port=22 (SSH)
Make sure you were using the correct parameters.

Then try this from the remote.

mysql -h <IP# of server/> -u <username/> -p <password/> -P 3306

The iptables are not usually the problem.
Posts: 7
fasulin
Joined: 25 Apr 2013
#6
hi, i can connect from remote, but only if i am in the intranet (192.168.0.x/24) with mysql , if my ip real is other, ex. 190.11.100.38 (from my house) i cannot connect __{{emoticon}}__
Posts: 630
Eino
Joined: 12 Oct 2012
#7
fasulin wrote:hi, i can connect from remote, but only if i am in the intranet (192.168.0.x/24) with mysql , if my ip real is other, ex. 190.11.100.38 (from my house) i cannot connect __{{emoticon}}__
At the server end make sure that port 22 for the ssh is not blocked. (your house)

then try the below

mysql -h <190.11.100.38/> -u <username/> -p <password/> -P 3306 ( via the internet )

post the errors you get. .

Use this link to check if your IP address it correct.
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://www.whatismyip.com/"
linktext was:"http://www.whatismyip.com/"
====================================


I just found an easy tutorial that may help.
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://www.rackspace.com/knowledge_center/article/mysql-connect-to-your-database-remotely#Notes"
linktext was:"http://www.rackspace.com/knowledge_cent ... tely#Notes"
====================================
Posts: 7
fasulin
Joined: 25 Apr 2013
#8
hi, i tried

mysql -h 190.11.100.38 -u <username/> -p <password/> -P 3306 ( via the internet )

and get error

ERROR 2003 (HY000): Can't connect to MySQL server on '190.11.100.38' (10060)

thanks
Posts: 630
Eino
Joined: 12 Oct 2012
#9
Take the folowing steps.

Comment bind-address in my.cnf:

# bind-address = 192.168.1.3

Grant privileges: GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY PASSWORD 'xxxx';

Set port forwarding on router (TCP and UDP, port 3306, 192.168.1.3)

Configure iptables for firewall

sudo iptables -I INPUT -p udp --dport 3306 -j ACCEPT

sudo iptables -I INPUT -p tcp --dport 3306 --syn -j ACCEPT

sudo iptables-save

Restart mysql server
sudo /etc/init.d/mysql restart

If you get the same error after the steps taken, it's possible that your ISP is filtering that port.
Please note The IP address above must be the local address of the server. the above may be different than shown.
Posts: 7
fasulin
Joined: 25 Apr 2013
#10
hi Eino, i tried but not function __{{emoticon}}__ ((

i checked firewall and it´s ok port open and forward. i can redirect other machine in the intranet and it´s ok, but server with antiX is blocked port __{{emoticon}}__ ((

Note: change in the iptables is not permanet changes, i used sudo iptables-save but i restart and iptable rules flushed

thank a lot.
Eino
Joined: 12 Oct 2012
#11
Use SU in the terminal instead of sudo with each line.
Do you know what port is blocked in antix? We can use another port.

Check the UFW type in the following as root." ufw status verbose" I want to see if it active or not.
We may need to set rules if antix's firewall is active.