I am writing a PHP script that is editing a named.conf file for DNS setup. ($named is the file)
-First i get user to input their ip address and turn there response into a variable $ipaddress
-Later on in the script, I am trying to replace the ip's that are already in the named.conf file with the new one.
OLD LINE: listen-on port 53 { 172.16.30.2; 127.0.0.1; };
EXAMPLE OF USER IP: 192.168.1.1
DESIRED OUTPUT: listen-on port 53 { 192.168.1.1; 127.0.0.1; };
The line that I am using to try to get this result is:
$named = preg_replace('/172.16.30.2/', $ipaddress, $named);
However, the result that I am getting is:
listen-on port 53 { 192.168.1.1
; 127.0.0.1; };
I don't know how to stop the new line from being added in after the variable is inputed. I also tried str_replace and had the same results.
Any ideas would be appreciated.