ioctl problem
Michael Velez
mikev777 at hotmail.com
Wed Sep 28 13:44:52 UTC 2005
-----Original Message-----
From: redhat-list-bounces at redhat.com [mailto:redhat-list-bounces at redhat.com]
On Behalf Of kanhu rauta
Sent: Wednesday, September 28, 2005 8:03 AM
To: redhat-list at redhat.com
Subject: ioctl problem
I want to add an alias IP into a particular interface through ioclt
call. I used SIOCSIFADDR and SIOCSIFNETMASK to add the IP with the
netmask. one problem here i am facing, instead of adding the alias IP it
replace the actual IP of that interface. In my code i gave the interface
name as "eth0" not "eth0:0 or eth0:1" due to some constrain.
int add_alias_ip(){
struct ifreq ifr;
int sockfd;
if( (sockfd=socket(AF_INET,SOCK_DGRAM,0))<0){
.....................
.....................
}
memset (&ifr, '\0', sizeof (ifr));
ifr.ifr_addr=AF_INET;
ifr.ifr_dstaddr=AF_INET;
ifr.ifr_netmask=AF_INET;
strncpy (ifr.ifr_name, "eth0", 4);
((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr =
inet_addr("192.168.50.11");
if (ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
.................
.................
}
((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr =
inet_addr("255.255.255.192");
if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
...................
...................
}
return 0;
}
pls give some suggestion.........
Kanhu Charan Rauta
Innomedia Techonologies Pvt. Ltd
#3278,12Th Main,
HAL 2nd stage.
Banglore-560008.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=subscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Hello Kanhu,
For all alias IP addresses I've seen, netmask was always 255.255.255.255.
I guess the alias IP netmask should at least be different from the one for
your main IP address. Have you tried that?
I may be barking up the wrong tree but it's worth a try.
Michael
More information about the redhat-list
mailing list