schris403 Posted November 6, 2008 Share Posted November 6, 2008 Does anyone know if it is possible to actually 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 from the system (ip address, netmask, gateway, dns servers) to populate fields where I can change them and then submit the changes back via ifconfig & route commands. Any help would be GREATLY appreciated. Thanks! Chris Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/ Share on other sites More sharing options...
ILMV Posted November 6, 2008 Share Posted November 6, 2008 Right, do you mean the device on which the PHP server is on, or the device that is viewing the site? Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683632 Share on other sites More sharing options...
JonnoTheDev Posted November 6, 2008 Share Posted November 6, 2008 If the IP values get saved to a file then you could do this by reading and writing to the file. The file must have the correct permissions in order to read/write. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683695 Share on other sites More sharing options...
schris403 Posted November 6, 2008 Author Share Posted November 6, 2008 The one I want to change the IP on is the server. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683828 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 visit your routers IP in your browser. Usually something like this: 192.168.1.254 Then change the IP for the name of the server you have. Call your ISP for more information. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683832 Share on other sites More sharing options...
schris403 Posted November 6, 2008 Author Share Posted November 6, 2008 The reason why I want to change the server is because I am runnning the apache server locally on a portable machine and want a way to change it via the web before I move it to another location. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683839 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 If you want to change it's IP, you'll need to do what I told you in my previous post. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-683864 Share on other sites More sharing options...
JonnoTheDev Posted November 6, 2008 Share Posted November 6, 2008 visit your routers IP in your browser You are confused. The post is not about modifying a routers configuration but the IP address of a physical machine. If you want to change the server settings remotely use PUTTY. You do not need PHP to do this. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684063 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 visit your routers IP in your browser You are confused. The post is not about modifying a routers configuration but the IP address of a physical machine. If you want to change the server settings remotely use PUTTY. You do not need PHP to do this. Exactly. How do you think I changed my servers IP to a static, I visited my browsers IP address, selected my machine, chose the correct IP, and changed it. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684070 Share on other sites More sharing options...
Mchl Posted November 6, 2008 Share Posted November 6, 2008 Not all (cheap) routers allow that mind you Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684078 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 I know Linksys allows you to do so. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684083 Share on other sites More sharing options...
Mchl Posted November 6, 2008 Share Posted November 6, 2008 Not mine (at least not with stock software... or It's so well hidden, that I don't really care to look for it). And even if it did, I can as well change my IP by changing network config on given PC. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684092 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 If you pop them a call, they'll give you detailed instructions. Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684127 Share on other sites More sharing options...
Mchl Posted November 6, 2008 Share Posted November 6, 2008 No local representative, and I don't fancy overseas call... and besides what for... I don't actually need it Quote Link to comment https://forums.phpfreaks.com/topic/131626-changing-ip-address-via-php/#findComment-684197 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.