I am using a service for smtp relay and they give me a smtp server url (mail.theirdomain).. I wanted to ask if there is any way of "masking" this for example with some dns records to make the mail.theirdomain, mail.mydomain?
Sure, you can do a DNS lookup of mail.theirdomain.com and see what IP address this hostname points to (e.g. x.x.x.x). Then, you can create a hostname mail.mydomain.com, and point this hostname to the same IP address (x.x.x.x).
But, if you do a reverse DNS lookup (i.e. PTR lookup) of x.x.x.x, it will likely point to mail.theirdomain.com (not mail.mydomain.com), and you can't change this, because you do not have control of x.x.x.x.
Also, if you open an SMTP connection to mail.mydomain.com, it will likely show mail.theirdomain.com in the SMTP banner that the server responds with after a client connects - and this is not something that you can change either.
Related
I'm creating a MySQL cluster and I want to use port 3306 for all of the MySQL instances and the only way I can think of to do that on one ip is to create a domain as hostname, but I can't figure out how o can add a domain as hostname.
Hope you can help.
Thanks
EDIT::
Expected result:
Able to connect to 2 MySQL Instances on a single network with one IP:
Network A: (ip: 8.8.8.8)
Instance 1: db1.example.com PORT 3306
Intance 2: db2.example.com PORT 3306
Network B: (ip: 8.8.8.9)
Instance 3: db3.example.com PORT 3306
Intance 4: db4.example.com PORT 3306
Web browsers present the Host header to web servers. A server, when it sees an incoming http or https request, uses that header to route the request to one of multiple web sites it's hosting.
For example, you can have the hostnames www.example.com and www.example.org both resolve to the IP address 10.254.253.252. Then when a browser makes a request to http://www.example.org , it will arrive at the server with the header Host: www.example.org.
But. the MySQL protocol doesn't have the equivalent of the Host header. Therefore, you can't do what you hope to do.
According to this document
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-remote-database-to-optimize-site-performance-with-mysql
To connect from external ip to mysql I have to change to public ip of the server
bind-address = your_database_IP
I put here my public IP server.
So my question is does it lose performance. Does it understand that this ip actually its on ip so it will act like local database? Or it will think it is external ip so goes in internet and comes back again ?
Connection possibilities:
Socket -- the fastest, but only works when client and server are on the same hardware (or, in some cases, the same VM)
TCP/IP on the same hardware, but through the TCP/IP stack, so slightly slower for queries.
Domain name lookup, and other issues dealing with establishing remote (not same machine) connection. This action is done only during connecting. So, it might slow down establishing the connection, but not the queries. Note: the translation from "foo.com" to "1.2.3.4", if needed, is done once, only during the establishment of the connection. An explicit IP address is faster, but less flexible.
Proxy server / load balancer / etc -- these sit between the client and the server, and add some delay (and some benefit) during all queries.
Connection pooling in the client -- some overhead or savings on connecting.
Connection pooling in the server -- some overhead or savings on connecting. (Whether to reuse a process (thread) versus create a new one.)
The beauty of TCP/IP is that you can send a message to any IP address you know; the 'network' will figure out how to get there (anywhere in the world). It may take one route now, another route the next time. So it is "reliable", but inconsistent is speed. It also has a good level of "guaranteed delivery". Once connected, that is what queries do -- send to a known IP address and get replies.
(See the other comments for more info.)
I have a situation, where I have a computer with multiple IP's, the computers primary IP will never change, but all the secondary IP's will.
I connect to a remote MYSQL computer and I have access granted based on my IP address. Sometimes, my PC likes to select one of the secondary IP's.
I looked in to the "Set As Source" flag and tested that solution, but what happens is, that I can't select those extra IP's for outbound communication.
Dim IPS As IPAddress() = Dns.GetHostAddresses(Dns.GetHostName())
Any IP with the "set as source" = false - won't be returned with the above code.
So how would I get around this dilemma? I can't seem to find a solution, with socket progamming I can bind any IP I want, but I don't see a way to do this with a mySQL connection.
Anyway, I was able to accomplish this by adding a second NIC on the Server and putting the single IP on 1 NIC and all the other IP's on the second NIC. Then putting in a route that forces the traffic through the Primary NIC interface to MySQL.
Without two NICS, you can't select which IP it uses, But with two you can assign the routes to either NIC (Interface).
I am unable to start my couchbase server. I am getting this error while I run the server.
supervisor: {local,inet_gethost_native_sup}
started: [{pid,<0.266.0>},{mfa,{inet_gethost_native,init,[[]]}}]
[error_logger:info,2015-01-06T18:14:37.164,nonode#nohost:error_logger<0.6.0>:ale_error_logger_handler:do_log:203]
=========================PROGRESS REPORT=========================
supervisor: {local,kernel_safe_sup}
started: [{pid,<0.265.0>},
{name,inet_gethost_native_sup},
{mfargs,{inet_gethost_native,start_link,[]}},
{restart_type,temporary},
{shutdown,1000},
{child_type,worker}]
[ns_server:warn,2015-01-06T18:14:37.189,nonode#nohost:dist_manager<0.264.0>:dist_manager:wait_for_address:118]Cannot listen on address `10.219.59.100`: eaddrnotavail
[ns_server:info,2015-01-06T18:14:37.189,nonode#nohost:dist_manager<0.264.0>:dist_manager:wait_for_address:122]Configured address `10.219.59.100` seems to be invalid. Giving OS a chance to bring it up.
[ns_server:warn,2015-01-06T18:14:38.190,nonode#nohost:dist_manager<0.264.0>:dist_manager:wait_for_address:118]Cannot listen on address `10.219.59.100`: eaddrnotavail
[ns_server:info,2015-01-06T18:14:38.190,nonode#nohost:dist_manager<0.264.0>:dist_manager:wait_for_address:122]Configured address `10.219.59.100` seems to be invalid. Giving OS a chance to bring it up.
Is it Ip address Problem ? My Ip address Is 10.219.59.102 but it looking for 10.219.59.100.
It sounds like the IP address the node was originally configured for has changed. If you don't specify a hostname as the node's name when you first configured the node, Couchbase will attempt to auto-detect the node's public IP address and use that. However if that IP address changes then it runs into problems.
Take a look at the Install guide, specifically the section on Using hostnames for how to change a node's name.
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.