简体   繁体   中英

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

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!

如果您具有root访问权限,则可以使用iptables对SNAT执行此特定目标的特定源IP:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM