Spring cloud Specifies IP or ignores a net card configuration when launching the app

Source: Internet
Author: User

Description: Distributed application deployment to the service, because the server may have more than one network card, resulting in the problem of IP address is not allowed.

Workaround:

1, directly add ignore the configuration of a net card:

spring.cloud.inetutils.ignored-interfaces[0]=eth0 # ignores eth0, supports regular expressions

Regular:

spring.cloud.inetutils.ignored-interfaces=eth.*

2. Specify the default IP:

spring.cloud.inetutils.preferred-networks=192.168. 20.123 #可以是IP段:192.168.  -

3, in addition to these configurations, there are the following configuration:

spring.cloud.inetutils.default-hostnamespring.cloud.inetutils.default-ip-  addressspring.cloud.inetutils.ignored-interfacesspring.cloud.inetutils.preferred-  Networksspring.cloud.inetutils.timeout-secondsspring.cloud.inetutils.use- Only-site-local-interfaces

Both the ignored-interfaces and Preferred-networks are configured. These two configurations determine the network card and IP address that spring cloud apps use when it starts. Ignored-interfaces receives a regular expression array, the configuration name is ignored-interfaces, ignoring the network card, but because it receives a regular expression, so we can arbitrarily select and reverse the machine's network card. Preferred-networks refers to an IP address that tends to be used, and receives an array of regular expressions to select the IP address of the native that the spring cloud app uses. With these two configurations, we can arbitrarily specify the network card and IP address used by the spring cloud app.

For more explanations, the Spring-cloud-commons project provides a top-level abstraction and infrastructure implementation for the spring cloud ecosystem. The basic infrastructure of the network is also implemented here: Inetutils, inetutilsproperties, and utilautoconfiguration provide network configuration-related functionality.

Reference:

http://blog.csdn.net/neosmith/article/details/53126924

Https://www.jianshu.com/p/90ec946293ee

http://blog.csdn.net/xichenguan/article/details/76557065

http://blog.csdn.net/tony308001970/article/details/75061217

Https://github.com/spring-cloud/spring-cloud-commons/blob/master/docs/src/main/asciidoc/spring-cloud-commons.adoc

Spring cloud Specifies IP or ignores a net card configuration when launching the app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.