Networking Forums

Networking Forums > Computer Networking > Linux Networking > Changing the IP address progrmmatically.

Reply
Thread Tools Display Modes

Changing the IP address progrmmatically.

 
 
Praveen
Guest
Posts: n/a

 
      11-25-2003, 10:46 AM
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.
 
Reply With Quote
 
 
 
 
Neil Horman
Guest
Posts: n/a

 
      11-25-2003, 11:22 AM
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
 
Praveen
Guest
Posts: n/a

 
      11-29-2003, 11:50 AM
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

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CHANGING TO NEW IP ADDRESS FROM SETUP ADDRESS Jeff Windows Networking 6 01-24-2007 08:46 PM
Changing IP address Neil G Jarman Windows Networking 4 03-27-2006 09:35 AM
IP Address changing Barry Windows Networking 1 09-07-2004 06:52 PM
Changing IP Address root Windows Networking 2 04-22-2004 08:17 PM
IP Address changing Robert Spike Wireless Internet 3 09-13-2003 10:22 PM



1 2 3 4 5 6 7 8 9 10 11