此内容没有您所选择的语言版本。

Appendix A. Java IPv4 and IPv6 properties


You can use Java properties to configure IPv4 and IPv6 addresses. You can subsequently export these properties to Tomcat and use address values to specify Tomcat bindings.

A.1. Overview of Java IPv4 and IPv6 properties

Java provides two properties that you can use to configure IPv4 and IPv6 addresses:

java.net.preferIPv4Stack (default: false)
If IPv6 is available, the underlying native socket is an IPv6 socket by default. This socket enables applications to connect and accept connections from IPv4 and IPv6 hosts. If applications use IPv4 sockets only, set this property to true. However, applications that are using IPv4 sockets only cannot communicate with IPv6-only hosts.
java.net.preferIPv6Addresses (default: false)
If a host has both IPv4 and IPv6 addresses, and IPv6 is available, the default behavior is to use IPv4 addresses over IPv6. This allows backward compatibility. If applications depend on an IPv4 address representation, such as 192.168.1.1, set this property to true to change the preference, and use IPv6 addresses over IPv4 where possible.

A.2. Exporting Java IPv4 and IPv6 properties to Tomcat

You can export Java IPv4 and IPv6 properties to Tomcat by setting CATALINA_OPTS in the JWS_HOME/tomcat/bin/setenv.* file. On Red Hat Enterprise Linux, the setenv file has a .sh extension. On Microsoft Windows, the setenv file has a .bat extension.

Procedure

  1. If the JWS_HOME/tomcat/bin/setenv.* file does not exist, create the file.

    Note

    If you are using Red Hat Enterprise Linux, create a setenv.sh file. If you are using Microsoft Windows, create a setenv.bat file.

  2. To export Java IPv4 and IPv6 properties to Tomcat, perform either of the following steps:

    • If you are using Red Hat Enterprise Linux, enter the following command:

      export "CATALINA_OPTS=-Djava.net.preferIPv4Stack=YOUR_VALUE -Djava.net.preferIPv6Addresses=YOUR_VALUE"
      Copy to Clipboard Toggle word wrap
    • If you are using Microsoft Windows, enter the following command:

      set "CATALINA_OPTS=-Djava.net.preferIPv4Stack=YOUR_VALUE -Djava.net.preferIPv6Addresses=YOUR_VALUE"
      Copy to Clipboard Toggle word wrap

A.3. Configuring Tomcat bindings

You can configure Tomcat bindings in the JWS_HOME/tomcat/conf/server.xml file by specifying the IPv6 address.

Procedure

  1. Open the JWS_HOME/tomcat/conf/server.xml file.
  2. To specify the Tomcat binding address, enter the following details:

    <Server ... address="TOMCAT_BINDING_ADDRESS">
    Copy to Clipboard Toggle word wrap
  3. To specify the HTTP connector address, enter the following details:

    <Connector protocol="HTTP/1.1" ... address="HTTP_CONNECTOR_ADDRESS">
    Copy to Clipboard Toggle word wrap
  4. To specify the AJP connector address, enter the following details:

    <Connector protocol="AJP/1.3" ... address="AJP_CONNECTOR_ADDRESS">
    Copy to Clipboard Toggle word wrap
Note

Ensure that you replace TOMCAT_BINDING_ADDRESS, HTTP_CONNECTOR_ADDRESS, and AJP_CONNECTOR_ADDRESS with the correct IPv6 address.

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat