Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
    
@lain, thanks for your answer. What about telnet? –  Cem Nov 13 '12 at 11:06
    
@Cem: updated my answer –  Iain Nov 13 '12 at 11:14
    
Great, thanks @lain. That did the trick. –  Cem Nov 13 '12 at 11:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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