Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

Changing the IP address progrmmatically.

Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2003, 11:46 AM
Default Changing the IP address progrmmatically.



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
Reply With Quote
  #2  
Old 11-25-2003, 12:22 PM
Neil Horman
Guest
 
Posts: n/a
Default Re: Changing the IP address progrmmatically.

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
************************************************** */

Reply With Quote
  #3  
Old 11-29-2003, 12:50 PM
Praveen
Guest
 
Posts: n/a
Default Re: Changing the IP address progrmmatically.

Neil Horman <(E-Mail Removed)> wrote in message news:<bpvijd$kf6$(E-Mail Removed)>...
> 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.
Reply With Quote
Reply

Tags
address, changing, progrmmatically

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.