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