I'm developing a system on Xamain in a way that each device can create network service via HttpListner then start listing for incoming calls from other devices on same LAN network. Upon creating the listner we can apply naming convention in the URI so that other devices can filterout non-related services.
The question is there a way to discover all hosts (ip+port) under same LAN having given service's prefix?
I could do it using device specific code for Android via NdsManager class then calling DiscoveringPeers() but I'm thinking why it's not possible to have equivalent functionality in .Net?
I used ZeroConf as source of inspiration to implement Multicasting clients and now all good. The most important is picking up the right Ip address adapted to your Network to multicast. See this table (https://en.wikipedia.org/wiki/Multicast_address).
Broadcasting to 255.255.255.255 was not the required behavior as well as it will not be routed.
Related
SMB's session setup packet contains both a NativeOS and NativeLanMan field that describe both host and client.
I have a need to determine if a network share is SAMBA or Windows Server to avoid a bug.
I know both of these do set unique fields for the setup packet but I am at a loss of finding a win32 api that may expose this info.
I have a .NET Kafka client (using librdkafka via a Confluent's .NET client) running on a physical server with two network interfaces active. One is 10G and the other is 1G, both of them have static IP addresses assigned. Our networking team handles the configurations and is unlikely to change their practices for one application so I'd like to handle this client-side. I should also mention that the 1G interface and 10G interfaces are on the same network.
Since my Kafka cluster (3-node) is all 10G, I would like to require my application's consumer to bind to the 10G IP address. Looking through all of the documentation, I can't find anything about defining this on the client.
I would like to avoid any "hacky" solutions like setting Kafka to deny any non-whitelisted IP addresses or DNS tomfoolery.
Thanks in advance!
Just to be sure.., Do you know if your server is doing interface bonding (means the traffic will load balance between each interface, though, it's unlikely to do binding on different speed interfaces..)?
If not, as your two interfaces are on the same network, it means you will only use one interface to reach the network (except if you have exotic routing config). This interface will be defined by your default route.
If it's a Linux server, you can do as follows :
ip route
default via X.X.X.X dev YOURDEFAULTINTERFACE
If it's the 10G, you have nothing to do and you can be sure it will use this interface.
If not, you cannot do anything Kafka side, as it's purely OS settings side. Your Kernel will forward any traffic through this default interface.
Again.. I insist on the fact that this is because both your interfaces are in the same network.
If you have any doubts with this, please share your network configuration in details ( result of ip addr and ip route)
Yannick
I have used netfilter hook functions to filter/sniff on outgoing IP packets. I'm looking to filter outgoing (from host) packets between IP layer and Link layer to look into Layer 2 information like - interface, MAC address. The NF_INET_POSTROUTING does not give mac address information as it is called in ip_output() before address resolution i guess.
I looked up ebtables hook functions, they seem to be related to Bridge INPUT/FORWARD/OUTPUT. If i understand, the outgoing packets from local tcp/ip do not go through bridge forwarding hooks. Is there way i can hook into packets between Linux IP and link layer to filter (DROP or modify) ...?
I am not sure if there's a generic way to hook this, but some methods come to mind:
LD_PRELOAD socket operations: Supply a shared library with your own implementation of send(|to|msg)
Register a virtual TAP interface and have your application bind to it
Register a virtual interface in-kernel and have your application bind to it
The bonding driver is an example of the latter. Behind the scenes, it scatters egress traffic to slave devices and gathers ingress traffic from them.
I tried this in my uman driver. You can configure via DebugFS an interface to micro-manage. Any application binding to the uman0 virtual interface will have its egress traffic pass through uman_start_xmit and ingress traffic via uman_handle_frame, where you can add code to decide whether to forward/mangle/drop the packet. uman was a side product of my bachelor thesis and might not be fit for production use (If you make it fitter, pull requests are welcome :-).
We are trying to create a simulation script where we need to send TCP packet data to the server in way that it appears to be coming from different IP every time.
Basically we need to emulate multiple devices ( with different IP) which are constantly sending data to the server.
The server creates a new connection only for request coming in from a new IP.
What is the best possible way to achieve it ? Is there a way of using proxy servers or some sort of virtualization to accomplish this ?
What you want to use is IP aliasing. This allows you to create virtual network interfaces. Each virtual interface can have one or more IP addresses assigned to it.
This link shows how to do it in Linux.
This link shows how to do it in Windows.
Next your clients need to specify which of your addresses to use. Use getifaddrs() to enumerate the available addresses. Then use the bind() system call on the socket before you do a connect(). This way you can have multiple clients and each one will use a different source IP address. This post has the details.
I am working on some legacy code on Windows for a desktop app in "C.
The client needs to know the geo-location of the user who is running the application.
I have the geo-location code all working (using MaxMind: http://dev.maxmind.com/).
But now I'm looking for help in getting their external IP.
From all the discussions on this topic throughout SO and elsewhere it seems that there is a way to do this by connecting to a "reliable" host (server) and then doing some kind of lookup. I'm not too savvy on WinSock but this is the technology that may be the simplest to use.
Another option is to use WinHttpConnect technology.
Both have "C" interfaces.
Thank you for your support and suggestions.
You can write a simple web service that checks the IP address(es) that the program presents when connecting to that web service.
Look at http://whatismyip.com for an example.
Note that multiple addresses can be presented by the HTTP protocol if there are proxy servers along the route.
You can design your simple web service to get the IP of the client. See
How do I get the caller's IP address in a WebMethod?
and then return that address back to the caller.
Note that in about 15% of cases (my experience metric) the geo location will be way off. The classic example is that most AOL users are routed through a small number of proxy servers. However, there are many other cases where the public IP does not match the user's actual location. Additionally, Geo IP databases are sometimes just wrong.
Edit
It is not possible to detect your external IP address using only in-browser code.
The WebSocket has no provision to expose your external IP address.
https://www.rfc-editor.org/rfc/rfc6455
You need an outside server to tell you what IP it sees.