How TCP/IP selects a source IP address
TCP/IP uses the following sequence to select the source IP address for an outbound packet. For detailed information about the TCP/IP profile (PROFILE.TCPIP) and configuration statements, see z/OS Communications Server: IP Configuration Reference.
Sendmsg that specifies the source address in the ancillary IPV6_PKTINFO data
If this is a UDP or RAW socket, and IPV6_PKTINFO ancillary data is specified on sendmsg() with a nonzero source IP address, this address is used as the source IP address.
Setsockopt IPV6_PKTINFO
If this is a UDP or RAW socket, and the IPV6_PKTINFO socket option is set and it contains a nonzero source IP address, this address is used as the source IP address.
Explicit bind to a specific local address
If the socket is already bound to a specific local IP address other than INADDR_ANY or |in6addr_any, TCP/IP uses this specific local IP address.
PORT profile statement with the BIND parameter
If the socket is bound to a port and to the INADDR_ANY or |in6addr_any IP address, and there is a corresponding PORT profile statement with the BIND parameter specified, TCP/IP uses the address specified by the BIND parameter.
SRCIP profile statement
If this is a TCP socket and either the socket is not yet bound or the socket is bound to the INADDR_ANY or |in6addr_any IP address, TCP/IP checks the job name and destination IP address against the SRCIP entries in the following order:
JOBNAME entries, other than JOBNAME *
DESTINATION entries
JOBNAME * entries
If a match is found, TCP/IP uses the designated source in the |most specific matching entry to provide the source IP address to be used.
TCPSTACKSOURCEVIPA parameter on the IPCONFIG or IPCONFIG6 profile statement
All of the following conditions must be met:
This is a TCP socket.
SOURCEVIPA is enabled on IPCONFIG or IPCONFIG6.
SOURCEVIPA is not disabled for the socket.
The application has not issued a specific bind for this socket, even to the INADDR_ANY or |in6addr_any IP address.
The address specified on the TCPSTACKSOURCEVIPA parameter is a static VIPA or active dynamic VIPA.
If these conditions are met and this is an IPv4 packet, TCP/IP uses the address specified on the TCPSTACKSOURCEVIPA parameter.
If these conditions are met and this is an IPv6 packet, TCP/IP uses the default source address selection algorithm to select one of the addresses configured for the VIPA interface referenced by the TCPSTACKSOURCEVIPA parameter. For information about the default source address selection algorithm, see z/OS Communications Server: IPv6 Network and Application Design Guide.
Guideline: Because the SRCIP profile statement provides all of the functionality of the TCPSTACKSOURCEVIPA parameter and additional granularity, consider using the SRCIP statement instead of specifying the TCPSTACKSOURCEVIPA parameter. Specifying JOBNAME * in a SRCIP profile statement provides the same result as specifying the TCPSTACKSOURCEVIPA parameter for implicit bind scenarios, and also applies to applications that issue a bind to the INADDR_ANY or |in6addr_any IP address.
SOURCEVIPA: static VIPA address from the HOME list (IPv4) or from the SOURCEVIPAINTERFACE parameter (IPv6)
All of the following conditions must be met:
SOURCEVIPA is enabled on IPCONFIG or IPCONFIG6.
SOURCEVIPA is not disabled for the socket.
Either the socket is not yet bound, or the socket is bound to the INADDR_ANY or |in6addr_any IP address.
If these conditions are met, TCP/IP determines the interface over which the initial packet will be sent.
For an IPv4 packet, TCP/IP does the following:
Locates that interface in the HOME list.
Searches backward in the HOME list for a static VIPA.
If a static VIPA is found in the HOME list, TCP/IP uses the first static VIPA found as the source IP address.
For an IPv6 packet, TCP/IP does the following:
Determines whether a SOURCEVIPAINTERFACE parameter was specified for the selected interface.
If so, uses the default source address selection algorithm to select one of the addresses configured for the VIPA interface that is referenced by the SOURCEVIPAINTERFACE parameter. For information about the default source address selection algorithm, see z/OS Communications Server: IPv6 Network and Application Design Guide.
HOME IP address of the link over which the packet is sent
For an IPv4 packet, TCP/IP uses the HOME IP address of the link over which the initial packet is sent.
For an IPv6 packet, TCP/IP uses the default source address selection algorithm to select one of the addresses configured for the interface over which the initial packet is sent. For information about the default source address selection algorithm, see z/OS Communications Server: IPv6 Network and Application Design Guide.
No comments:
Post a Comment