Link to home
Start Free TrialLog in
Avatar of phoffric
phoffric

asked on

How to get unix client to use higher speed NIC in its socket?

In multi-homed UNIX box, for servers, we can bind a specific IP address (or all of them) and ports to the socket. In sample client code, I just see the client socket associated with the server's IP address and port. I would like this client to connect to a server using only the client's higher speed card's IP address. Does anyone have some IPv4 sample client code to do this showing both the server and client socket association in the client code? (I am dealing with straight IP addresses, so DNS is not part of this topic.) My understanding is that without this binding, the client will use "lan0" (100 Mbps) instead of "lan1" (1Gbps).
Thanks,
  Paul
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phoffric
phoffric

ASKER

"route" did work on my platform, but did on another. I take it that you want to look at the routing table. I found netstat does it. Here is what I got:
# netstat -rnv
Routing tables
Dest/Netmask                                  Gateway            Flags Refs Interface  Pmtu
127.0.0.1/255.255.255.255            127.0.0.1              UH      0    lo0               32808
19.140.131.67/255.255.255.255   19.140.131.67     UH      0    lan1            32808
19.140.131.32/255.255.255.255   19.140.131.32     UH      0    lan0            32808
19.140.128.0/255.255.252.0          19.140.131.67     U         2    lan1              1500
19.140.128.0/255.255.252.0          19.140.131.32     U         2    lan0              1500
127.0.0.0/255.0.0.0                          127.0.0.1               U         0    lo0               32808
default/0.0.0.0                                  19.140.128.1        UG      0    lan1              1500

>>  I believe the "metric" value should be able to affect how this happens.
Could you explain what you mean by the "metric" value? Thanks.

BTW, I am not using this platform as a server; but rather as a workstation. /etc/hosts has three entries: 127.0.0.1, 19.140.131.67, and 19.140.131.32. (But, on a reboot, the .67 and .32 end up with the platform's name, and I have to change .67 manually to have two distinct names.)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The unix version is hp-ux 11i v3 (aka hp-ux 11.31).

To clarify my comment that "route" did work on my platform, but did on another, what I saw on hp-ux was:
# route
usage: route [inet6] [ -n ] [ -f ] [ -p pmtu ] [ cmd [ net | host ]  args ]
But, on a VM GNU/Linux, typing "route" shows the routing table.

Looking at the man pages on both platforms, I see that the GNU/Linux "route" has "show / manipulate the IP routing table"; whereas the hp-ux "route" omits the "show" part. That is why I used hp-ux "netstat" to show the routing table.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OP>> I would like this client to connect to a server using only the client's higher speed card's IP address.

Thank you for your inputs. I think the first two posts are in agreement in that when making a connection, the decision as to which NIC to use is not within the control of the application. (I should have tagged this as hp-ux to avoid the confusion.)

>> your lan1 route is still higher in the order so I would have assumed that would be the route chosen.
Looking at the last line:
     default/0.0.0.0                                  19.140.128.1        UG      0    lan1              1500
I am just guessing here.. This seems to suggest that lan1 (the higher speed NIC) is the interface to the gateway. Perhaps that is the answer to the sub-question alluded to - how to know which NIC is used when two can both reach the destination.

BTW - iproute2 does not appear to be in this hp-ux platform.

I will look into this further, and post any findings that I come up with.

Regards,
Paul