Skip to content

Commit

Permalink
ssh: optional bind interface if bind address specified.
Browse files Browse the repository at this point in the history
Allows the -b and -B options to be used together.
For example, when the interface is in the VRF.
  • Loading branch information
Dmitrii Turlupov authored and djmdjm committed Feb 26, 2021
1 parent 1fe4d70 commit 5a878a7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sshconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ ssh_create_socket(struct addrinfo *ai)
}
memcpy(&bindaddr, res->ai_addr, res->ai_addrlen);
bindaddrlen = res->ai_addrlen;

/*'-B' option*/
if (options.bind_interface != NULL) {
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, options.bind_interface, strlen(options.bind_interface) + 1))
debug("error: setsockopt SO_BINDTODEVICE");
}
} else if (options.bind_interface != NULL) {
#ifdef HAVE_IFADDRS_H
if ((r = getifaddrs(&ifaddrs)) != 0) {
Expand Down

0 comments on commit 5a878a7

Please sign in to comment.