This is a discussion on Changing the IP address progrmmatically. within the Linux Networking forums, part of the Linux Forums category; Hello, Can anybody tell me if there exists a way to programmatically change, retrieve the IP of a NIC and ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
Can anybody tell me if there exists a way to programmatically change, retrieve the IP of a NIC and modifying the routes in Linux.. I tried doing it with rtnetlink but since i din't get any good documentation on it other than man pages, have got stuck up.. any pointers to some good documentation on the same or some tutorials will be of gr8 help to me.. Thanx in advance.. -Praveen M Nair. |
|
|||
|
Praveen wrote:
> Hello, > Can anybody tell me if there exists a way to programmatically change, > retrieve the IP of a NIC and modifying the routes in Linux.. > > I tried doing it with rtnetlink but since i din't get any good > documentation on it other than man pages, have got stuck up.. any > pointers to some good documentation on the same or some tutorials will > be of gr8 help to me.. > > Thanx in advance.. > -Praveen M Nair. The ioctl system call is what you want. You need to open a socket and call ioctl on the socket descriptior to issue the SIOCGIFADDR/ SIOCSIFADDR commands. These allow you to specify a data structure which contains both an interface name and address to set or retrieve. HTH Neil -- /************************************************** * *Neil Horman *Software Engineer *Red Hat, Inc., http://people.redhat.com/nhorman *gpg keyid: 1024D / 0x92A74FA1 *http://www.keyserver.net ************************************************** */ |
|
|||
|
Neil Horman <nhorman@rNeOdShPaMt.com> wrote in message news:<bpvijd$kf6$1@stan.redhat.com>...
> Praveen wrote: > > Hello, > > Can anybody tell me if there exists a way to programmatically change, > > retrieve the IP of a NIC and modifying the routes in Linux.. > > > > I tried doing it with rtnetlink but since i din't get any good > > documentation on it other than man pages, have got stuck up.. any > > pointers to some good documentation on the same or some tutorials will > > be of gr8 help to me.. > > > > Thanx in advance.. > > -Praveen M Nair. > The ioctl system call is what you want. You need to open a socket and > call ioctl on the socket descriptior to issue the SIOCGIFADDR/ > SIOCSIFADDR commands. These allow you to specify a data structure which > contains both an interface name and address to set or retrieve. > > HTH > Neil Thanx Neil. But i have another dilemma, that is i have known that ioctls don't work for IPV6, but in some sample codes for ioctls i have come accross lines where they are checks for IPV6. any comments on this will be helpful... -Praveen M Nair. |