pinging dynamic IP server - ping

I invoked ping process on ubuntu, then while ping works the IP of server has been changed.
another ping process from the same machine showed me the correct IP, but the first process still printing old IP.
that can be variable in ping, initialized once when it start (I guess, anybody here can confirm it?).
however I wonder to know how it works.

Couldn't it be an DNS Cache problem?
If you think yes, try that:
sudo /etc/init.d/dns-clean start

Related

phpmyadmin server name change

I am really new in this kind of stuff so my question might be to easy or stupid but please do help this newbie.
When I opened my phpmyadmin, the server was named: mysql wampserver. Usually in tutorials, their server name was localhost. Can you please tell me how to change the name of the server if possible so I can use the tutorial easier if we have the same sever name.
Thank you in advance!
That name is absolutely irrelevant to anything. It is actually set in this file wamp\apps\phpmyadmin4.1.14\config.inc.php using this parameter
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
It effects nothing and if it really bothers you you can amend it to anything you like
$cfg['Servers'][$i]['verbose'] = 'Mackinley Databases on my PC';
The WAMP server doesn't maintain a name. You connect to it via an IP address... do you not know the IP of the machine it's installed on?
If it's on your own computer, you can connect to the Sql server from code by connecting to 127.0.0.1:3306 (default port).
If it's not on your machine, find the ip address of the machine it's running on by going to the command prompt and typing 'ipconfig'.
Then use that IP address and port 3306 (or whatever port you defined, 3306 is just default)
Default access will be via localhost or 127.0.0.1. Might not work (rarely) if it was modified before.
Also Check you Host file. make a copy of before editing host file ..

C/Mysql refuses to connect to remote IP

I am writing a program in C which accesses a mysql database. Everything functions great except one simple problem. On my development machine the database is hosted locally (localhost) and I have no problems. When I moved the program to a production system and altered the IP to that of the production mysql database, the machine still attempts to access mysql on localhost. I am rather confused and I don't even know where to begin with searching for the cause.
#define server "192.168.0.1"
mysql_init(&mysql);
connection = mysql_real_connect(&mysql, server, user, password, database, 3306, NULL, 0);
if (!connection) {
printf("%s", mysql_error(&mysql));
return 1;
}
I also tried it like this:
mysql_init(&mysql);
connection = mysql_real_connect(&mysql, "192.168.0.1", user, password, database, 3306, NULL, 0);
if (!connection) {
printf("%s", mysql_error(&mysql));
return 1;
}
And no matter what, the machine throws this error:
Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock'
Which I believe is an attempt to bind to a local pipe instead of a remote socket. When I move back to my development machine and deliberately use the 192.168.0.1 address (which isn't even an address that exists in the development network) the program operates perfectly again, as it is just connecting to localhost. Even though I specified an IP address.
I know that when I connect to mysql via command line $(mysql -hlocalhost) it defaults to using a pipe instead of a socket such as if I used $(mysql -h127.0.0.1). I may have those backwards.. But it appears to be doing that. It's completely ignoring the IP and connecting via the local pipe. What on earth am I doing wrong??
I hope I explained that correctly. And I hope it's a stupid simple mistake that is obvious. Thank you guys.
**Note: addresses changed for security purposes
EDIT:
Interestingly I ran strings on the binary and it didn't output the DNS address I put in as a response to the most recent post. This suggests to me maybe something about the compile process. For some reason it is seeing the string I am entering as perhaps NULL and automatically converts it to 'localhost' in the binary.
It appears to be a problem either with the compile or my source. But I don't see why it would be interpreting my string incorrectly and replacing it I guess on the assumption that it is unreadable or 'NULL'.
What am I doing wrong? :/
EDIT: Ok! Im an idiot. I rewrote the entire gcc command from scratch and all works well. Apparently my fingers don't work at 5am and using the up arrow to reuse a broken command all day doesn't fix the problem no matter how much code I write.
Thank you guys. Sorry for wasting your time!

Swiftmailer Gmail Connection timed out #110

I want to send emails using gmail's smtp with the PHP script posted below using Swiftmailer. Now this works fine on my own webserver. But when I used it on the webserver of the people I'm creating this for, I get an exception:
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' in ...
What could be the problem?
I'm assuming its got to do with the difference in server settings, because the code works on my own webserver. I've checked with phpinfo() the following:
- Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
- OpenSSL support enabled
- OpenSSL Library Version OpenSSL 1.0.1e-fips 11 Feb 2013
This is my PHP code:
$emailname = MY_GMAIL_ACCOUNT_USERNAME;
$emailpass = MY_GMAIL_ACCOUNT_PASSWORD;
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername($emailname)
->setPassword($emailpass);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($emailtitle)
->setFrom(array($emailname.'#gmail.com' => $emailsender))
->setTo(array($emailrecp))
->setBody($emailbody,'text/html');
$result = $mailer->send($message);
I had the same issue on a Digital Ocean server. Turns out they're blocking SMTP by default on IPv6. Here's the fix:
nano /etc/gai.conf
precedence ::ffff:0:0/96 100
as per:
https://www.digitalocean.com/community/questions/outgoing-connections-on-port-25-587-143-blocked-over-ipv6
My easy solution to avoid the problem of dynamic IP (every time i ping smtp.gmail.com I see a slight difference in the last 3digit chunk), is to simply use php built-in gethostbyname() to read the IP in real-time.
$smtp_host_ip = gethostbyname('smtp.gmail.com');
$transport = Swift_SmtpTransport::newInstance($smtp_host_ip,465,'ssl')
->setUsername('username')->setPassword('pwd');
Im not advanced in php and streams but it seems that IPv6 DNS resolution depends on the router and/or ISPs. I changed my provider, got a new router and the smtp connection always timed out.
To use IPv6 you should either add your own IPv6 or force stream_context_create to use IPv4. You can call setSourceIp() on a swiftmailer object or directly change the Swift_SmtpTransport class (i.e. in the constructor).
Use IPv6:
// replace IP with your own IPv6
$this->setSourceIp('2aaa:8a8:fc0:230:fds:4fd:faa:24ae');
Use IPv4 (mentioned at https://github.com/phergie/phergie/issues/195):
$this->setSourceIp('0.0.0.0');
just add
74.125.130.108 smtp.gmail.com
to server's hosts file
I've just been doing battle with exactly the same problem. Mine worked locally too, but as soon as it got on a real server ... no. It just would not work even though all the settings were the same.
After many hours, I've think I've found out why.
What seems to happen is that on a server with IPv4 and IPv6 support, IPv6 takes precedence. Which makes sense, given that it's newer. But in the case of smtp.gmail.com, it appears to only listen on IPv4. So when the server resolved smtp.gmail.com, it got its IPv6 address back and so PHP tried to connect to it. That eventually gives up with a "Connection timed out" exception. Now you would think that fsockopen, presumably, would detect the connection wasn't working and so try IPv4, but seemingly it doesn't.
If you find out what smtp.gmail.com's IPv4 address is (ping smtp.gmail.com) and simply put that IP in place of the hostname in the code - it works :)
It's not ideal coding in an IP address - given that Google could change it at any minute - but at least you will get some emails sent
The answer for me was that my server was blocking the outbound connection. It could be your firewall or your host.
The way to test this is to try connecting yourself. I used telnet on two different machines to compare and it became obvious that this was my issue. There may be a way to test this with curl directly.

phpmyadmin (wamp) not working anymore

I've played a little with php and data bases a few weeks ago and it worked perfectly. Now, when I tested the same thing again, I realized that it is not runnable anymore. More exactly, when I have to access the data base, I get the following type of notice:
Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in E:\wamp\www\test\login.php on line 18
When I try to open http://localhost/phpmyadmin/ I get a blank screen
Please give me the possible explanations
You probably have another application using port 3306, another MySQL running perhaps?
The Possible explanation is
i suspect you have installed and uninstalled wamp? in that case you need to check you driver/etc/.hosts file under system32 ("Google it for exact path") :) and you have to make sure there exist only one value for
127.0.0.1 localhost
As it said above you need to check your running port has already used by another instance by checking
netstat -a and see if 3306 is Listening
Check on windows services that MySQL ,Apache are running or able to run automatically or manually from the service
suggest uninstall properly ==> delete all inside the wamp folder except www --takecare

Users can't connect remotely to MySQL

Problem
Users from other IPs on the (Windows XP) LAN suddenly cannot connect to my local MySQL server.
Background
I've set up MySQL on my local Windows computer so that other computers on the network have access to the root account. I've added each IP as a host for root. Up to some weeks ago, things worked flawlessly and I could connect to the server programatically and using various MySQL admin tools. Now, however, the MySQL server simply refuses connections from those IPs and I can't figure out why.
The network changes that I've done are: changing network card for two (of three) computers and fiddled around with MySQL settings. None of which should have caused this problem. I've tried adding a new user with all relevant hosts, but I get the same type of error:
MySQL Error number 1045 Access denied
for user 'root'#'shop' (using
passwords: YES)
The odd part is that the computer name, 'shop', is used instead of the IP. I don't know why.
Somehow, IPs seem to be resolved now and hostnames are used. Did you grant access to root#shop? Did you flush privileges?
First thing that pops into mind is Windows Firewall, which could have got re-enabled if you swapped NICs on the host computer.
My next suggestion would be to use a sniffer like Wireshark on the host computer and see what exactly happens packet-wise. You can use filters to make to reduce the output - they're very simple and easy to use. This tool has saved me countless hours of debugging.
-EDIT-
Another possible cause might be that your server somehow decided to resolve IPs to hostnames, in which case ip addresses may no longer work - one would need to add hostnames to the allowed list. Not sure if it works this way for MySQL though.
Could you have turned off TCP connections in MySQL?
Also, is the MySQL port open in your firewall?
If you changed your IP (DHCP?), make sure to correct it in my.cnf if you bound mysqld to your lan ip:
[mysqld]
...
bind-address=192.168.x.y