I do it at the OS level via the adaptor properties for windows. If your network 
does not support IPv6 I would disable it else you will get errors in your logs 
about IPv6 for like say DHCP assignment.
 
Regards,
-Tony

--- On Sun, 7/22/12, k9...@operamail.com <k9...@operamail.com> wrote:


From: k9...@operamail.com <k9...@operamail.com>
Subject: Tomcat 7.0.27 listens only @IPv6 localhost, ignores 'use IPv4' 
JAVA_OPTS in tomcat.conf. How to correctly force IPv4?
To: users@tomcat.apache.org
Date: Sunday, July 22, 2012, 9:03 AM



I've installed

    rpm -qa | grep -i ^tomcat
        tomcat-lib-7.0.27-7.1.noarch
        tomcat-docs-webapp-7.0.27-7.1.noarch
        tomcat-javadoc-7.0.27-7.1.noarch
        tomcat-webapps-7.0.27-7.1.noarch
        tomcat-admin-webapps-7.0.27-7.1.noarch
        tomcat-servlet-3_0-api-7.0.27-7.1.noarch
        tomcat-7.0.27-7.1.noarch
        tomcat-el-2_2-api-7.0.27-7.1.noarch
        tomcat-jsp-2_2-api-7.0.27-7.1.noarch


with

  update-alternatives --config java
  There are 2 choices for the alternative java (providing
  /usr/bin/java).
  
    Selection    Path                                       Priority  
    Status
  ------------------------------------------------------------
    0            /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java   17147    
    auto mode
  * 1            /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java   17147    
  manual mode
    2            /usr/lib64/jvm/jre-1.7.0-sun/bin/java       1700     
    manual mode

on

    uname -a
        Linux svr 3.1.10-1.16-desktop #1 SMP PREEMPT Wed Jun 27
        05:21:40 UTC 2012 (d016078) x86_64 x86_64 x86_64
        GNU/Linux

IPv4 is enabled on the server.  The IPv6 stack is also enabled, and
necessarily configured as,

    grep bindv6only /etc/sysctl.conf
        net.ipv6.bindv6only = 1

I want Tomcat listening on the IPv4 localhost @ 127.0.0.1.

So, reading here -
http://tomcat.10.n6.nabble.com/Tomcat-uses-IPv6-td2164369.html#a2164371
- and elsewhere, I set

    vi /etc/tomcat/tomcat.conf
        ...
        JAVA_OPTS="Djava.net.preferIPv4Stack=true
        -Djava.net.preferIPv4Addresses=true"
        CATALINA_OPTS="Djava.net.preferIPv4Stack=true
        -Djava.net.preferIPv4Addresses=true"
        ...

now, @ tomcat start,

    ps ax | grep tomcat
     6530 ?        Sl     0:03 /etc/alternatives/jre/bin/java
     -Djava.net.preferIPv4Stack=true
     -Djava.net.preferIPv4Addresses=true
     -Djava.net.preferIPv4Stack=true
     -Djava.net.preferIPv4Addresses=true -classpath
     :/usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar
     -Dcatalina.base=/usr/share/tomcat
     -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs=
     -Djava.io.tmpdir=/var/cache/tomcat/temp
     -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.properties
     -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
     org.apache.catalina.startup.Bootstrap start

but, Tomcat still listens only on IPv6

    netstat -pan --tcp | grep 8080
        tcp        0      0 :::8080                 :::*        
                   LISTEN      6530/java

and is unavailable/unreachable @ 127.0.0.1

    telnet 127.0.0.1 8080
        Trying 127.0.0.1...
        telnet: connect to address 127.0.0.1: Connection refused

    telnet ::1 8080
        Trying ::1...
        Connected to ::1.
        Escape character is '^]'.
        telnet>

has the method for getting Tomcat to listen only @ IPv4 changed for v7?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to