0

I reffered many links to change IP address using C/C++. But I found that its only changing the setting temporary (untill the next reboot) and Once the system is rebooted , the all settings are gone.

I referred below links to achieve it.

Qt: Setting the IP

Set IP address using SIOCSIFADDR ioctl

etc. but ended up with temporary settings (remains untill the next reboot)

Is there any way to change the settings permanently through C/C++ ?????

Please direct me to the right path.

Community
  • 1
  • 1
skg
  • 948
  • 2
  • 19
  • 35
  • 2
    Yes: change the system configuration. Try on a Linux forum (e.g. where/how the settings are stored and applied). Off Topic. –  Nov 21 '12 at 05:47
  • 1
    Try unix.stackexchange.com or similar with your specific distro. For example, config in Debian/Ubuntu lives in /etc/network/interfaces. – beatgammit Nov 21 '12 at 06:43

1 Answers1

3

At startup Linux uses some configuration file to assign IP-address to an interface. Each distribution has its own file dedicated for that purpose. You should consult your distribution Wiki on the topic of how to set an IP-address at startup.

In general it is an administrative task (i.e. should not be configured dynamically via some custom program), but if you really want to do it in your C/C++ program, then you should parse the network configuration file and place there the address you want to assign at startup.