Re: Programatically change IP Address



Tauno Voipio <tauno.voipio@xxxxxxxxxxxxx> writes:

>ibondre@xxxxxxxxx wrote:
>> How can i programatically change the IP Address, DNS, gateway,
>> Enable/disable DHCP, in Linux Using C or C++.
>>
>> Is there also an API to get this properties?

Why?
The dns server is in /etc/resolv.conf. The gateway is set by the route
command or the ip command in more modern situations.
The address of the card is set either by dhcp or by ifconfig.

You can run programs from within your C program (execle)


>The DNS and DHCP settings are in configuration files
>you can modify if you have sufficient access rights.

>To effect the changes you may need to send a signal
>to the corresponding daemon or to restart it.

>The IP addresses and routing information are in
>kernel tables which are accessible with suitable
>ioctl() calls. For details, get a book on network
>programming, e.g.

> W. Richard Stevens, UNIX Network Programming

>Needless to say that the process modifying any network
>settings needs sufficient privileges.
.



Relevant Pages

  • Re: Non-domain connection problem
    ... Yesterday I even hardcoded the DNS of a local ISP into the TCP/ip properties ... Connect to Internet from Internal Network ... Notice that the default gateway and DNS IP addresses are different, ...
    (microsoft.public.windows.server.sbs)
  • Re: Static IP Address HELP !!
    ... Everything should work once I change that gateway address. ... >> to change is to close your DNS Virtual Server on your ... >> using dynDNS to host your DNS externally, ... > Network card on ...
    (microsoft.public.windows.server.sbs)
  • Re: Need help with my network
    ... Connection specific DNS suffix....domain_not_set.invalid ... Until recently, this connection worked great. ... can't get the wired one to show up on the network. ... the IP addresses for the computer, the gateway, and DNS. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Domain controller not found
    ... You said the router is x.x.1.4 and now you say the gateway "knows"? ... This address has nothing to do with your network. ... So the 192.168.0.1 is not longer used on any server or workstation? ... It just seems that the DNS ...
    (microsoft.public.windows.server.setup)
  • Re: Dynamic DNS ??? default gateway ???
    ... I don't think this had anyhting to do with the default gateway or dns. ... it is not on their network and there is no static route for the network ... > two networks together is some of the servers. ...
    (microsoft.public.win2000.networking)