<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Derek Adams on Medium]]></title>
        <description><![CDATA[Stories by Derek Adams on Medium]]></description>
        <link>https://medium.com/@derekjadams?source=rss-f1b4c4cbf36e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j7PipAta48PfuiHg.jpg</url>
            <title>Stories by Derek Adams on Medium</title>
            <link>https://medium.com/@derekjadams?source=rss-f1b4c4cbf36e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:09:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@derekjadams/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Connect to a Remote MySQL Server on the Same Subnet in your DMZ]]></title>
            <link>https://medium.com/@derekjadams/how-to-connect-to-a-remote-mysql-server-on-the-same-subnet-in-your-dmz-523521d2d55?source=rss-f1b4c4cbf36e------2</link>
            <guid isPermaLink="false">https://medium.com/p/523521d2d55</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[api-integration]]></category>
            <dc:creator><![CDATA[Derek Adams]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 15:41:52 GMT</pubDate>
            <atom:updated>2018-08-16T13:41:40.411Z</atom:updated>
            <content:encoded><![CDATA[<p>The issue I encountered revolved around allowing an API server to directly connect to a MySQL server on the same subnet in our DMZ. While this sounds like it should be entirely straightforward, headaches were had.</p><h3><strong>First Thing to Check</strong></h3><ol><li>You have the proper MySQL user privileges set up for access from your remote IP address. Run this command to check your MySQL user permissions.</li></ol><pre>select User, Host from mysql.user;</pre><p>You should see your remote server IP (the api server) along with the user you are trying to connect as.</p><p>2. If you don’t see your permissions set properly, I would recommend adding permissions for both IP and hostname. Before you start, you should also flush your privileges.</p><pre>FLUSH PRIVILEGES;</pre><pre>GRANT ALL PRIVILEGES ON *.* TO &#39;xuserx&#39;@&#39;api.xxhostnamexx.com&#39;<br>IDENTIFIED BY &#39;xxxpasswordxxxx&#39;<br>WITH GRANT OPTION;</pre><pre>GRANT ALL PRIVILEGES ON *.* TO &#39;xuserx&#39;@&#39;111.111.111.111&#39;<br>IDENTIFIED BY &#39;xxxpasswordxxxx&#39;<br>WITH GRANT OPTION;</pre><p>3. Once permissions are confirmed correct, run a tcpdump on your MySQL server to ensure you are receiving connections from the API server.</p><pre>tcpdump -i eth0 host 111.111.111.111</pre><p>In your tcpdump, the first value after the -i is the interface name of your source server (the MySQL server in this case). The second value after host is the IP address of API server that will be making the remote MySQL connection. To find the interface name binded to your source server IP address, run:</p><pre> ip a</pre><p>4. While you leave your tcpdump running on the MySQL server, run a telnet to port 3306 on the API server, connecting to the MySQL server.</p><pre>telnet 111.111.111.110 3306</pre><p>5. While looking at your tcpdump, you will see SYN go out from API, SQL responds with SYN-ACK, Then API sends ACK. This ensure the threeway handshake was a success and you have no network connectivity issues. <strong>If you do not see that communication make it to the MySQL server, you have a network or firewall issue.</strong></p><h3>If there is no networking issues, proceed on.</h3><p>At this point, as long as your MySQL permissions are properly set and your API server properly connects to your MySQL server, you should have no issues directly connecting via terminal to your remote MySQL connection from the API server.</p><p>Run the following to confirm:</p><pre>mysql --host=111.111.111.110 --port=3306 -u xuserx -p</pre><p>You will be prompted for password and successfully logged in.</p><h3>The Kicker</h3><p>In my scenario, I was able to get the direct remote MySQL connection working from command line after fixing my MySQL permissions, however my API application still failed to connect.</p><p>While looking at the tcpdump on the MySQL server, I noticed that no inbounded connections were coming in from the API server when I ran a request via HTTP.</p><p>After further digging, I found that SELinux was actively blocking the outbound MySQL request. This was found by looking at the linux audit log file, located here:</p><pre>/var/log/audit/audit.log</pre><p>In order to fix that problem, you have to run the following command:</p><pre>sudo setsebool -P httpd_can_network_connect=1</pre><p>After enabling http_can_network_connect, all is working.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=523521d2d55" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>