IPv6, also referred to as the next-generation protocol, is a superset of the existing IPv4 networking foundation. IPv6, which is compatible and interoperable with IPv4, allows you to upgrade your Internet devices. For more information on IPv6, refer to my previous article, "Discover Internet Protocol version 6 (IPv6)," which you can check out in Resources.
In this article, I'll show you how to configure IPv6 for two FTP servers: Orenosv 1.0, which is compatible with Microsoft® Windows®, and vsftpd 2.0.1-5, which is compatible with Linux®. You'll use the IBM® Java™ Runtime Environment (JRE) 1.5.0 to write and execute the sample Java application.
Configuring the Windows FTP server Orenosv for IPv6
You can download the Orenosv FTP server from the Orenosv site (see Resources). Let's see how to configure the server to listen to and accept IPv6 addresses.
First, download and install the server, which will install by default in $Drive/Program Files/Orenosv. Create the user account and its default directory. Go to the installation location, open passwd.txt, and add this line:
ipv6:ipv6:/ftpusers/ipv6
In this line, ipv6 represents the user, ipv6 represents the password, and ftpusers/ipv6 represents the user directory location. Figure 1 shows what the final passwd.txt file looks like.
Figure 1. Final passwd.txt file representation

Next, create the user directory location ftpusers/ipv6 in $Install_Location/ftproot. Your final directory structure looks like this:
$Install_Location\ftproot\ftpusers\ipv6
Provide the Access control for the ipv6 user that you created. Go to $Install_Location, open acl.txt, and add this line:
ftpuser/ipv6/* ALL="_all_" ALL="@admin"
The final acl.txt file looks like Figure 2.
Figure 2. Final acl.txt file representation

Next, add the ipv6 user to the admin group. Go to $Install_Location, open grpdb.txt, and add the user to the admin group, like this:
admin:admin1,admin2,ipv6
Figure 3 shows what the final grpdb.txt file looks like.
Figure 3. Final grpdb.txt file representation

To enable the FTP server to accept IPv6 requests, go to $Install_Location and open http.conf. Uncomment these lines in the http.conf file:
ftp_enable = 1 ftp_listen = 0.0.0.0@21 ftp_port_srcport = 20 |
Comment all the Secure Sockets Layer (SSL) entries in the http.conf file, and add this line for IPv6 support:
ftp_listen=IPv6Address@21
IPv6Address represents the machine IPv6 address. Here's an example with a real IP address:
ftp_listen = 2002:9b8:708a:0:0:0:0:1@21
To restart the server, navigate to Start > Programs > Orenosv and click Restart Orenosv Service. Check that the FTP server is running and can listen to the IPv6 request. To do this, open the command prompt and connect to the FTP server using the IPv6 address. If your login is successful, it will look like Figure 4.
Figure 4. Successful login to FTP server

If the login fails, check the configuration and try again.
Configuring the Linux FTP server vsftpd for IPv6
The vsftpd server comes with Red Hat Enterprise Linux (RHEL) by default. Let's configure the server to listen to and accept IPv6 addresses.
First, login as the root user and open vsftpd.conf, which is usually located in the /etc/vsftpd directory. Comment this line in the vsftpd.conf file:
listen=yes
Add this line for IPv6 support in vsftpd.conf:
listen_ipv6=yes
To restart the vsftpd server, use the service vsftpd restart command. If it fails to restart, check the vsftpd.conf entries.
Writing a sample FTP client program
Let's write a simple Java FTP client program that does the following:
- Connects to the FTP server using the IPv6 numeric address
- Displays the files present in the user login directory after establishing a connection to the server
- Prompts the user to enter the filename to download
- Exits after downloading the respective file from the FTP server
You can download the zip file (see Downloads), which has the complete code with all the related files to run the program; see more instructions on this in the Running the Java application section. Listing 1 explains the program's core logic.
Listing 1. Sample Java program to get files from FTP server enabled for IPv6
package com.ibm.ipv6.ftp;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import sun.net.ftp.FtpClient;
/**
* @author Makham Kumar
*
*/
public class IPv6FTPClient extends FtpClient{
private static final String sourceClass = "IPv6FTPClient";
private static final String SPACE= " ";
private static final String SEP = "-";
private static final String LINE = "\n";
public IPv6FTPClient(){ }
public static void main(String[] ipv6Main) {
final String sourceMethod = "main";
BufferedReader bRead = null;
IPv6FTPClient ipv6Ins = null;
String strOption = null;
String strFileName = null;
boolean bStatus = true;
try {
if(ipv6Main.length == 3)
{
ipv6Ins = new IPv6FTPClient();
ipv6Ins.loginToMachine(ipv6Main[0], ipv6Main[1], ipv6Main[2]);
ipv6Ins.listFileSets();
// Capturing details from the user to download files from the FTP server
do {
console(LINE+LINE+SPACE+"Want to download a file ? [Y/N] : ");
bRead = new BufferedReader(new InputStreamReader(System.in));
strOption = bRead.readLine();
if(strOption.equalsIgnoreCase("Y"))
{
console(LINE+SPACE+"Enter the file name to download : ");
strFileName = bRead.readLine();
bStatus = ipv6Ins.getFile(strFileName);
}
else if(strOption.equalsIgnoreCase("N"))
{
bStatus = false;
ipv6Ins.closeServer();
console(LINE+LINE+SPACE+"Closing the FTP server connection "+LINE);
}
else
{
bStatus = false;
console(LINE+LINE+SPACE+"Entered invalid option.");
}
} while (bStatus);
bRead.close();
}
else
{
console(LINE+"Entered invalid arguments");
}
console(LINE+LINE+SPACE+"Application existing !!!"+LINE+LINE);
}catch(Exception eM)
{
eM.printStackTrace();
console(LINE+"Application existing !!!"+LINE+LINE);
}
finally
{
try {
if(bRead != null)
bRead.close();
} catch (Exception eFinally) {
eFinally.printStackTrace();
}
}
}
/**
* This utility method connects to FTP server using Username and Password
* @return void
*/
private void loginToMachine(String strMachine, String strUser, String strPasswd)
{
final String sourceMethod = "loginToMachine";
try{
openServer(strMachine);
login(strUser,strPasswd);
console(sourceMethod,"Successfully connected to FTP server");
binary();
} catch(Exception eLogin)
{
eLogin.printStackTrace();
System.exit(0);
}
}
/**
* This utility method lists the names of the files in
* the respective FTP user directory
* @return void
*/
private void listFileSets()
{
final String sourceMethod = "listFileSets";
String fileName;
BufferedReader reader = null;
try{
reader = new BufferedReader(new InputStreamReader(list()));
while ((fileName = reader.readLine()) != null) {
console(LINE+fileName);
}
reader.close();
}catch(Exception eList)
{
eList.printStackTrace();
}
finally
{
try {
if(reader != null)
reader.close();
}catch (Exception eFinally) {
eFinally.printStackTrace();
}
}
}
/**
* This utility method downloads the file from the FTP server to
* the location where this Java program is executed
* @return boolean
*/
private boolean getFile(String fileName)
{
final String sourceMethod = "getFile";
boolean bStatus = false;
BufferedInputStream bInputStream = null;
FileOutputStream fOutputStream = null;
String strPath = "."+File.separator+"download"+File.separator;
try {
bInputStream = new BufferedInputStream(get(fileName));
fOutputStream = new FileOutputStream(strPath+fileName);
int iStart = 0;
byte[] byteArray = new byte[1024];
while ((iStart = bInputStream.read(byteArray)) >= 0) {
fOutputStream.write(byteArray, 0, iStart);
}
fOutputStream.close();
bInputStream.close();
console(sourceMethod,"Successfully downloaded the file : "+fileName);
bStatus = true;
} catch (Exception eGetFile) {
eGetFile.printStackTrace();
}
finally
{
try {
if(fOutputStream != null)
fOutputStream.close();
if(bInputStream != null)
bInputStream.close();
} catch (Exception eFinally) {
eFinally.printStackTrace();
}
}
return bStatus;
}
/**
* This utility method prints the text to console
* @param String - Source method name
* @param String - Message text
* @return void
*/
private static void console(String sourceMethod, String msgText)
{
System.out.println(LINE+SPACE+sourceClass+SEP+sourceMethod+SEP+msgText);
}
/**
* This utility method prints the text to console
* @param String - Message text
* @return void
*/
private static void console(String msgText)
{
System.out.print(msgText);
}
}
|
The application is packaged in a compressed file. Unzip the file and download it into the SampleAppl directory. The lib directory contains the application in Java Archive (JAR) format, as well as the complete Java source code. All the files from the FTP server are downloaded into the download directory. The Run.bat and Run.sh files are OS-specific script files that run the application. To run the application, open either Run.bat for Windows or Run.sh for Linux, and edit the values of these login details:
set IPV6ADDRESS="$IPV6_ADDRESS" set USERID="$USERID" set PASSWD="$PASSWD" set JAVA_HOME_15="$JAVA_HOME_15" |
For example, your login details might look like this:
set IPV6ADDRESS="2002:9b8:708f:0:0:0:0:1" set USERID="ipv6" set PASSWD="ipv6" set JAVA_HOME_15="C:\Makham\was\wasnd\java" |
Open the command prompt, navigate to the directory where the script files are unzipped, and execute Run.bat or Run.sh, as shown in Figure 5.
Figure 5. Application output information

After a successful login, the application lists the files and prompts the user to enter the file to download. This example uses Welcome.txt. The application loads Welcome.txt, places it in the download directory, and then exits.
Congratulations! You've successfully configured an FTP server for IPv6 and received files from the FTP server using a Java application.
You just learned how to configure and write a Java program to communicate with IPv6-enabled FTP servers. You can apply these concepts to write Java applications that can communicate with other IPv6-enabled servers, such as Simple Mail Transfer Protocol (SMTP) and Post Office Protocol version 3 (POP3).
| Description | Name | Size | Download method |
|---|---|---|---|
| Sample code for this article | wa-ftpipv6-SampleAppl.zip | 6KB | HTTP |
Information about download methods
Learn
- Discover Internet Protocol version 6 (IPv6) (Makham V. Kumar, developerWorks, June 2006): Learn about the concepts, benefits, and industry compliance of this next-generation protocol.
- Writing a simple IPv6 program (Senthil Sundaram, developerWorks, September 2001): Configure an IPv6 address and port an IPv4 application to IPv6.
- Orenosv 1.0: Download and get the configuration information from the Orenosv HTTP/FTP Server home site.
- vsftpd.conf: Learn more details about configuring various server attributes in the vsftpd.conf file.
- IPv6 home page: Visit this IPv6 site, which features various topics pertaining to IPv6.
- IPv6 Related Specifications: Learn more about the Internet Engineering Task Force's (IETF's) Requests for Comments (RFCs) and IPv6 specifications.
- Linux IPv6 HOWTO: Find more information about how to configure IPv6 on Linux.
- Networking IPv6 User Guide for J2SDK/JRE 1.4: Explore the property settings you need to write Java applications that support IPv6.
- The IPv6 Forum: Browse this Web site to learn about the latest discussion topics.
- Ziff Davis Web Buyer's Guide: IPv6: Discover other products in the industry that support IPv6.
- developerWorks Web architecture zone: Expand your Web-building skills.
- developerWorks technical events and Webcasts: Stay up-to-date with new and current technology.
Get products and technologies
- IBM trial software: Build your next development project with software available for download directly from developerWorks.
Discuss
- developerWorks blogs: Get involved in the developerWorks community.

Makham V. Kumar works with the development team for IBM WebSphere Partner Gateway at IBM India Software Labs. His primary interests are working with the emerging technologies in Java 2 Platform Enterprise Edition (J2EE), the business integration domain, and developing tools based on open source and WebSphere. Makham is an engineer from the University of Karnataka at Belgaum, India.
Comments (Undergoing maintenance)





