I need to make a telnet conversation and this brought me to use official telnetlib library, widely explained here: telnetlib. The machine that actually use this software has several IPs, but it seems telnetlib does not provide an easy - or evident, at least - way to change my IP used in the handshake phase of telnet conversation.
Anyone has some useful information about that?
The source to telnetlib is here, and it appears it does not provide any way to specify the IP of the socket, leaving it up to the OS to select, which will result in the 'default' network interface.
https://hg.python.org/cpython/file/2.7/Lib/telnetlib.py#l227
The
create_connection()
signature is:You could copy the telnetlib.py and modify the
create_connection()
I have not tested this! But it could be like this on l227
or even add a keyword arguments to the open() call to pass in the desired interface info.