Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-21-2008, 05:52 AM   #1
LQ Newbie
Registered: Feb 2008
Location: Manila, Philippines
Posts: 2

Rep: Reputation: 0
Cannot create an IPv6 virtual IP (alias interface) using ioctl(SIOCSIFADDR)

Good day.

First all, thank you for viewing this thread.

Currently, I am porting my codes from Solaris 10 to RHEL 4 AS.
But, I am having trouble when it comes to creating "IPv6" virtual interfaces in the RHEL environment.

In Solaris, I was able to successfully create IPv4/IPv6 virtual interfaces by using the ioctl() in the following order.

1. ioctl (cli_LIFsd, SIOCLIFADDIF, &stLIF); // Creating a logical interface
2. ioctl (cli_LIFsd, SIOCSLIFADDR, &stLIF); // Defines the IP address of the new interface.
3. ioctl (cli_LIFsd, SIOCSLIFNETMASK, &stLIF); // Defines the netmask of the new interface
4. ioctl(cli_LIFsd, SIOCSLIFFLAGS, &stLIF); // Sets the new logical interface UP

I have inserted my RHEL test snippet below. Using the ioctl() SIOCSIFADDR request I was able to create an IPv4 virtual interface via AF_INET. But, was unsuccessful when creating an IPv6 via AF_INET6.
I can't even create a logical interface in IPv6. Kindly see the test snippet below.

# uname -a
Linux harrier 2.6.9-55.ELsmp #1 SMP Fri Apr 20 16:36:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

========================== RHEL Test Snippet ==========================
int cli_LIFsd;
struct ifreq stLIF;
struct sockaddr_in6 *stSockAddr6;
int rtnval;

/* create a stream-type socket in the Internet domain */
cli_LIFsd = socket(AF_INET6, SOCK_STREAM, 0);

/****** Creating a logical interface ******/
memset (&stLIF, 0x00, sizeof (struct ifreq));
strncpy( stLIF.ifr_name, argv[3], sizeof( stLIF.ifr_name ));
stLIF.ifr_addr.sa_family = AF_INET6;

stSockAddr6 = (struct sockaddr_in6 *)&(stLIF.ifr_addr);
inet_pton(AF_INET6, argv[1], &(stSockAddr6->sin6_addr));
rtnval = ioctl (cli_LIFsd, SIOCSIFADDR, &stLIF);

if (rtnval < 0)
perror("Perror message " );
printf ("Errno: %s [%d] \n", strerror( errno ), errno );

close (cli_LIFsd);
exit (1);

============================== Output ==============================

[root]# ./cli 2008:77:77::77 8888 eth0:777
Perror message : No such device
Errno: Illegal seek [29]

Added Questions:
1. Are there no problems when creating IPv6 virtual interfaces in RHEL?
Bugs.. maybe? need .. patch?
2. What are the RHEL ioctl requests (Ex. SIOCSIFADDR, etc.) needed to successfuly create an IPv6 virtual interface?

I am open to suggestions or you could point me to a site that would be very relevant.

Thank you very much.

Last edited by the_rock; 02-22-2008 at 03:28 AM.
Old 08-20-2010, 01:26 PM   #2
LQ Newbie
Registered: Aug 2010
Posts: 3

Rep: Reputation: 0
Any luck on this?

I'm trying to set the ipv6 for an interface using ioctl()... can you please let me know if a solution has been found?

Some more information --
I'm able to set an ipv6 address using ifconfig. I'm surprised that ioctl() doesnt work.


Last edited by seepatplay; 08-20-2010 at 01:28 PM.
Old 08-20-2010, 04:14 PM   #3
LQ Newbie
Registered: Aug 2010
Posts: 3

Rep: Reputation: 0

My bad... I was facing a permissions issue

Anyways, heres the solution --
struct ifreq ifr;
struct in6_ifreq ifr6;

socv6=socket(AF_INET6, SOCK_DGRAM, 0);
ioctl(socv6, SIOGIFINDEX, &ifr);

ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = 64;
ipv6add= (struct in6_addr *)&ifr.ifr_addr;
inet_pton(AF_INET6, "fe80::19", &ifr6.ifr6_addr);


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create routing between virtual interface in linux attojung Linux - Networking 2 03-13-2009 01:06 PM
How to create a virtual interface? Whyte Linux - Networking 2 03-27-2007 01:07 PM
Failed to activate interface : SIOCSIFADDR: No such device wlan0: hasnain Linux - Wireless Networking 1 04-11-2005 11:13 AM
Cooked IOCTL() interface: WTF??? kopikat Linux - General 1 01-05-2005 05:47 AM
Cooked IOCTL() interface: WTF??? kopikat Linux - Newbie 0 01-03-2005 03:55 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration