1

I have ~20 public IP addresses defined on my server. Now, when I connect to a remote server via terminal, it gets connected from the primary IP of my server.

But I want to use terminal from my another IP address. Is this possible?

  • 2
    What do you mean by "via terminal"? Are you looking for a way to change the source IP address of all connections to a particular machine? Or are you looking for a way to invoke a specific program so that it makes a connection from a particular IP address? Or something else entirely? – David Schwartz Nov 13 '12 at 9:31
  • Sorry for the confusion. I meant "telnet", not "terminal". – Cem Nov 13 '12 at 11:05
4

If you are using ssh to connect to the remote host then you can use the BindAddress directive to specify a local address to us for the connection

BindAddress Use the specified address on the local machine as the source address of the connection. Only useful on systems with more than one address. Note that this option does not work if UsePrivilegedPort is set to “yes”.

You can use this like so

ssh user@remote.tld -o BindAddress=ip.add.re.ss

You can also configure your ~/.ssh/config file to do this on a per host basis.

Host remote.tld
    BindAddress ip.add.re.ss

Host another
    BindAddress ss.er.dda.pi

Note that the Host matched has to be the same as that specified on the command line but you can use wildcards.


If you're using telnet then use the -b switch

-b address Use bind(2) on the local socket to bind it to a specific local address.

telnet -b ip.add.re.ss remote.tld
| improve this answer | |
  • @lain, thanks for your answer. What about telnet? – Cem Nov 13 '12 at 11:06
  • @Cem: updated my answer – user9517 Nov 13 '12 at 11:14
  • Bind option is not available to me. Why? telnet [-4] [-6] [-8] [-E] [-K] [-L] [-N] [-S tos] [-X atype] [-c] [-d] [-e char] [-k realm] [-l user] [-f/-F] [-n tracefile] [-r] [-s src_addr] [-u] [-P policy] [host-name [port]] – technazi Dec 11 '18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.