简体   繁体   中英

Change IP settings programmatically in Linux with C/C++

How to change the IP settings [mainly IP address, subnet mask and default gateway] in Linux using C/C++ ? I've seen examples that uses sockets but there are not much [besides they don't work]. I've tried this question but it does not work.

Whenever I try the code I use ifconfig to see my network configuration but they are still the same. I have openSUSE 13.2 and have both wireless and ethernet available connections.

I think another solution would be is to change the corresponding script file for the interface but I can't find these script files' locations.

In most cases, such kind of operations requires root access. Run your application with root rights and it'll make it work.

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