LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Changing an IP address via php? (https://www.linuxquestions.org/questions/linux-general-1/changing-an-ip-address-via-php-681504/)

schris403 11-06-2008 07:42 AM

Changing an IP address via php?
 
Does anyone know if it is possible to change an IP address on a system via php? I have been trying different things for days and can't seem to get it to work. I know I can call ifconfig via php via system("ifconfig"); and I have safe mode turned off to make this work. I will eventually put a safe_mode_exec_dir in my php.ini with ifconfig in there but really could use some help writing this first... Basically I want a page where it will first read the current IP values (ip address, netmask, gateway, dns servers), populate the fields where I can change them and then submit the changes back via ifconfig & route commands.

Any help would be GREATLY appreciated.

Thanks!
Chris

TB0ne 11-06-2008 08:56 AM

Quote:

Originally Posted by schris403 (Post 3333395)
Does anyone know if it is possible to change an IP address on a system via php? I have been trying different things for days and can't seem to get it to work. I know I can call ifconfig via php via system("ifconfig"); and I have safe mode turned off to make this work. I will eventually put a safe_mode_exec_dir in my php.ini with ifconfig in there but really could use some help writing this first... Basically I want a page where it will first read the current IP values (ip address, netmask, gateway, dns servers), populate the fields where I can change them and then submit the changes back via ifconfig & route commands.

So you know how to do it, via the system() call....what are you having problems with? Parse out the ifconfig first, to pull out the values you stated above, then parse out the results of /etc/resolv.conf and netstat -nr, to build your page. String-substitution later on, so your edited values will be written back...

schris403 11-06-2008 12:24 PM

I'm having problems with parsing the data, I think I'm gettting it into php but am not sure.. I'm not really well versed in php so am just really guessing at things and researching a ton to get it to work. What whould I use to parse the data?

Thanks!


All times are GMT -5. The time now is 01:39 AM.