How to bind Network Interface for C++ gRPC client

寵の児 提交于 2021-02-11 15:58:58

问题


Our system has an whitelist based on IP address to specify which gRPC client is allowed to connect. once before a new remote gRPC client join the network, the end user has to add its ip into the white list. Most time, it's easy for end user to know which NIC(ip) will be used by the gRPC client, but If there is too many NIC(ip) in the gRPC client node, it's hard for the end user to know which ip will be used before it's running, 'cause which NIC(ip) to be used is determine by the Linux system by default. Maybe 'route -n' command can be used to know the NICs priority, but the end user has to login via ssh, it makes a very bad user experience. So, Our customer deliver a new requirement which suggest us to bind a specified ip address for the gRPC client. I know it's easy for a normal socket programme to use 'bind' routine to bind an ip address for the client socket, but I don't know if there's some way for gRPC client(C++) to do that.


回答1:


gRPC doesn't have a way to bind a certain NIC when connecting to a server. You might need to get help from OS. https://unix.stackexchange.com/questions/338338/configure-a-process-to-use-specific-nic/338357 appears to be relevant.



来源:https://stackoverflow.com/questions/62710179/how-to-bind-network-interface-for-c-grpc-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!