0

first apologies if this is a v stupid question - forgive me - but i cannot make heads or tails for this scenario.

I created a python server script (basic socket script) that binds localhost and port 9999 on my PC. Next on my virtualbox (Linux mint) I run a simple telnet connection.

This is whats confusing the heck out of me - on my 'server'

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((_host, _port))
    s.listen(3)  
    print (f'Listening on {_host} and port {_port}')
    _conn, _addr =s.accept()
    print(f'Server IP/Port {_conn.getsockname()} Established')
    print(f'Client IP/Port {_addr} Established')

I can see that the python script is binding to port 9999 And when i run telnet from linuxmint I can see that the telnet session is connecting to the server

But i cannot co-rrelate the port that is on linuxmint vs what i see on my windows 10 python script

So ... This is the output from the python code snippet :

Listening on and port 9999
Server IP/Port ('192.xxx.xxx.xxx', 9999) Established
Client IP/Port ('192.xxx.xxx.xxx', 53016) Established
Listening on and port 9999

BUT Confirming this on windows netstat : Established 9999 192.xxx.xxx.xxx 53016 192.xxx.xxx.xxx

However; on the virtualhost when I do

netstat-tp

I get ... Local Address :55638

Question I have is what is 55638 and why dont i see 53016 as a port on linuxmint ??

Please can you help - i tried netsat -a | grep 53016 (nothing) but netstat -a | grep 55638 gives me the telnet hit.

Please can you help.

Thanks

  • Your formatting broke down towards the end of the question, so I'm not sure I understand what you're really asking about. But if it's the client port numbers you're seeing, those are usually randomly determined by the OS on the client machine. If you connect several different times you might do so with different client ports each time. And different OSs may have different algorithms for choosing the port numbers. – Blckknght Apr 30 '20 at 01:49
  • by default virtualbox uses NAT type of adapter for guests so when IP frame passes through this NAT src IP and src port are getting changed. – Maxim Sagaydachny Apr 30 '20 at 08:21
  • Blckknight (cool name btw) thank you for the reply. In python i create a process that binds to a socket (i give a port # 9999) To test this i telnet from virtual box and my python script sees port 53016 which i am assuming is the port that the telnet session on linuxmint vbox is using I confirmed this by running Get-NetTCPConnection | ft state,l*port, l*address, r*port, r*address -Auto in win10(PS) now on vbox - open a xterm and do a netstat and grep for 53016 port i dont see it ? Instead the telnet command is using port 55638. – Neale Chaudhury Apr 30 '20 at 13:34
  • Maxim i will check your theory but if i do xterm on vbox thats before the NAT happening so i should see the port - unless you are saying that what the server python script is seeing is the translated port and netstat is giving me the 'actual' port ! i will check this - v v v good point ! – Neale Chaudhury Apr 30 '20 at 13:35
  • Maxim you are correct the vbox NAT was sending a random port #. – Neale Chaudhury Apr 30 '20 at 19:48
  • Yes - confirmed - so i created a second VM archlinux and set up bridged adapter meaning that this VM will have its own ip under the subnet of my gateway - vs the first VM that will be using my host IP and (had been) set up as a NAT. So in this case same port number. LOL, forgot the basic fundamentals ... – Neale Chaudhury May 01 '20 at 03:05

0 Answers0