PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 13, 2022

[FIXED] Binding to a specific ip address when using the PHP mysql_connect function

 January 13, 2022     lamp, linux, mysql, php, proxy     No comments   

Issue

I have a Cent OS setup running a pretty standard LAMP stack and I have two publicly available IP addresses (eth0 and eth0:1).

I want to use the second IP address (eth0:1) when connecting out to a remotely hosted MySQL database. How can I go about that?

Thanks!


Solution

If you have root access, you can do SNAT with iptables to use a specific source IP for this particular destination:

iptables -t nat -A POSTROUTING -o eth0 -d <mysql_server_ip> -j SNAT --to-source <source_ip>


Answered By - jman
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing