Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoteHostIP & RemotePort are empty #8

Closed
dragokas opened this issue Sep 8, 2020 · 8 comments
Closed

RemoteHostIP & RemotePort are empty #8

dragokas opened this issue Sep 8, 2020 · 8 comments

Comments

@dragokas
Copy link

dragokas commented Sep 8, 2020

About security:

ctxServer_ConnectionRequest, requestID=676, RemoteHostIP=, RemotePort=0 63064,41

Is that a bug with RemoteHostIP / RemotePort, so we unable to verify the sender?

@wqweto
Copy link
Owner

wqweto commented Sep 10, 2020

Yes, this is a regression. I'll see to it some time when I get back in front of my PC next week.

@dragokas
Copy link
Author

dragokas commented Sep 29, 2020

Thanks a much for your time to fix ip. That works now.
I have several questions about it, if you don't mind.

Sorry, if they are too noob-like.

Following image demonstrates sending packets from host to guest VM and vice versa (that is a previous patch w/o port fix yet):
socket_error

Host:
ip - 192.168.31.4
gateway - 192.168.31.1

VM:
ip - 192.168.202.169
gateway - 192.168.202.1

  1. When I listen on "localhost" or "127.0.0.1" (no matter VM, or host) I cannot send a packet - saying "cannot connect ..."
    Is it a normal behaviour? The only way to receive a packet between network interfaces is to set the listener on current ip (192.168.31.4 (host) or 192.168.202.169 (vm)).

  2. Listener (on host) said that the packet came from 192.168.31.4 which is its own ip! That is not correct since I sent it from vm.
    Vice versa. Litener on VM said that the packet came from 192.168.202.1 which is its gateway =)
    Maybe it is some specific behind inter-network interfaces transferring mechanism, so packet is losing info about its original sender...

  3. Another case. Maybe you could suggest how correctly open port to see it externally from Internet and be able to send packets?

  • I made port forwarding on 8088 in my router.
  • I added inbound and outbound rule for Listener application to my windows firewall.
  • I set listener on "localhost" with that port.
    Now I connected via RDP to another physical machine out of my local network to test is my port 8088 opened,
    e.g. site: https://www.yougetsignal.com/tools/open-ports/
    however, it shows me that the port is closed. Surely, this powershell command also failed:
Test-NetConnection my.external.ip.address -Port 8088
  • Also, I tried to set Listener on "my.external.ip.address" instead of "localhost", but such operation failed with runtime error: "Required address is incorrect for its context".

Very appreciate your answers, when you have time.

@wqweto
Copy link
Owner

wqweto commented Sep 29, 2020

When I listen on "localhost" or "127.0.0.1" (no matter VM, or host) I cannot send a packet - saying "cannot connect ..."

Try listen on 0.0.0.0. This will listen both on localhost and all other assigned local IPs.

. . . said that the packet came from 192.168.31.4 which is its own ip

Is this VirtualBox? (No, I see it's VMWare now.) It uses NAT for VM networks by default. Try setting network to bridged and assign IP from your real LAN card subnet.

. . . made port forwarding on 8088 in my router.

If your VM is bridged it has "real" IP from your LAN subnet so you can forward directly to it. If forwarding is not working to your real machine probably listener was setup incorrectly on 127.0.0.1.

When you start listener on 0.0.0.0 the Windows Firewall will popup a dialog suggesting to add your application to firewall inbound rules. This will be an indication your listener is setup correct :-))

@dragokas
Copy link
Author

dragokas commented Oct 24, 2020

Lot of thanks for your detailed explanations! They was very helpful. Everything works.

One question: by design, when we are listening for a "localhost" only "preferred" network interface is catched.
What if we have 2 local network interfaces, but I want to listen for that second localhost interface (without 0.0.0.0, so a port should be invisible to the world). Is it possible?

@wqweto
Copy link
Owner

wqweto commented Oct 24, 2020

You have to listen to a specific local IP address that is assigned to this second LAN adapter.

Since commit 186a4dd you can use GetLocalHost method to retrieve an array with all local IPs as returned from GetAdaptersInfo API.

I can tweak it to return more info like network name or default gateway address, not only IP and subnet mask as currently impl.

@dragokas
Copy link
Author

dragokas commented Oct 24, 2020

Is there a method to pass the whole array of IPs (subnet) from the second adapter to listen for?

@wqweto
Copy link
Owner

wqweto commented Oct 24, 2020

No, you can either bind a socket on 0.0.0.0 (so called INADDR_ANY to listen on all local IPs) or bind it to a single local IP address.

127.0.0.1 is the IP address of the local loopback adapter but so is 127.0.0.2 and every other address in 255.0.0.0 subnet so you can listen on (and connect to) all these addresses too.

@dragokas
Copy link
Author

Ok, thank you.
I was thinking about trick to temporarily make second adapter to be preferred, then server.Listen "localhost", than return first adapter to be "preferred". Not sure, can it work that way =) Perhaps better just listen for 0.0.0.0 and use firewall to restrict external access to a port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants