Using Telnet on a Secondary IP Address

In order to test to see if a remote server was blocking the main IP of a server, I had to try to make a manual connection from the secondary IP. It wasn’t exactly obvious to me on how to do that so I just wanted to put this out there so it may help someone else as well.

So let’s say my server has 3 different public IP addresses:

1.1.1.1 –Main IP
2.2.2.2
3.3.3.3

Then let’s say trying to connect to a remote server, 9.9.9.9, on port 25 to send mail, but it doesn’t respond to ping, telnet, or even a traceroute. By default the connection would come out of the main IP of the server, but to test the connection from the other IP’s run:

telnet -b 2.2.2.2 9.9.9.9 25

So this makes a connection and binds it (hence the b) to the ip 2.2.2.2, connects out to 9.9.9.9 on port 25. If it works that means that the other server could just be blocking the main ip. If that doesn’t work there could still be other issues, possibly a firewall issue on my server’s end like port 25 not being open for outgoing.

If you try to bind to an ip not on your server, it gives an error:

telnet -b 4.4.4.4 9.9.9.9 25
Trying 9.9.9.9…
Couldn’t bind to 4.4.4.4
4.4.4.4: Cannot assign requested address

 

Add Comment