ZMQError: Cannot assign requested address - zeromq

I'm using zeromq to develop a dynamic application which operate like upnp protocol( autoconfiguration and auto-discovery of equipment on a living room).
To do it so, i use zeromq to distribute messages, my problem is that when i create a socket and binding on a adress "169.254.1.0 through 169.254.254.255", I receive a error messages like this: ZMQError: Cannot assign requested address.
I've tried to figure out why by changing the address by local adress (127.0.0.1),and it's works !!.
The problem is that i'm implementing autoip, it's means that i'm oblliged to use the adresse on range 169.254.1.0 through 169.254.254.255.
Thanks in advance for your help!

I got this error, too... and I realized I had the wrong idea of who was connecting to whom in the PUB/SUB model.
This was working: Host A as the ZMQ PUB, and could easily connect with Host A as the ZMQ SUB.
Then I tried to set up Host B as the SUB, and have Host A "send" to that... and I kept getting this error. After all don't you need to tell the PUB where to send the data?
No! Host A as the PUB should still bind to IP_ANY (0.0.0.0); it is Host B as the SUB who has to be configured with the address of Host A.
Once I got that straight in my code (and in my head), I was up and running.

After you bring the interface up, you need to get its IP address and then bind on that. Alternatively you may be able to bind on "*", meaning all interfaces.

Related

WFP driver giving 0.0.0.0 as local ip address for connection

I am implementing a callout routine for WFP driver doing connection redirection. I have registered at the FWPS_LAYER_ALE_CONNECT_REDIRECT_V4 layer. Everything is working fine.
When I am trying to get the local IP address for the connection, I always get it as 0. Is this expected? I am redirecting the connection to local service.
local_ip = RtlUlongByteSwap(inFixedValues->incomingValue
[FWPS_FIELD_ALE_CONNECT_REDIRECT_V4_IP_LOCAL_ADDRESS])
IN const FWPS_INCOMING_VALUES *inFixedValues received as parameter for callout routine.
The same is the case for user sid. It always comes like s-1-0-0 which is basically invalid sid
I am fetching user's sid blob as
inFixedValues->incomingValue[FWPS_FIELD_ALE_CONNECT_REDIRECT_V6_ALE_PACKAGE_ID].value.sid
Need help in understanding is this expected behavior or something I am missing here!
thanks
This isn't documented behavior as far as I know, but I've seen this callout be invoked twice for UDP connections: the first time with zero-values for the local address and port and the second time with actual values. It's been reported here and here. I work around it by checking the address and port fields for zero-values and ignoring the callout in that case.

Generating requests which appear to be coming from multiple IP's

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.

can't get message using twilio

I'm using Twilio to send and respond to messages. It was working normally, but since we moved to bay area the responding function doesn't work now.
So what happens is when the user send message to us(the IP address of our own computers) from their phones, our server can't receive anything. When we check our Twilio account, we know that the msg was indeed sent to the Twilio server. So we think it's the problem of linking between Twilio server and our IP address. We are suspecting that the IP address is virtual IP address here, which makes Twilio server can't find us. Is our suspection correct? if yes, what should we do? If not, what would be the possible problems?
Apologize for having a description not very clear, but it's pretty much everything of the problem. Please tell me if you need any additional information.
You probably need to use a dynamic dns service. Then you need to find what port Twilio sends the SMSs to the client(your computer), and make sure your firewall is forwarding that port to your computer. Odds are this is a firewall issue, especially since you say everything worked before you moved. Has there been a change in your network setup? You need to be aware of both hardware and software firewalls in your setup.
How is the firewall configured on your router? You need to forward requests to your router to your local IP address. Example: My local ip is 192.168.1.5 my external ip is 245.932.4.3 (This is the value you get from myipaddress.com) Thus you need to set your router (which has ip 245.932.4.3) to forward requests on port x (where x= the twilio outgoing port) to 192.168.1.5

Node.js EADDRNOTAVAIL can't access via external IP

app = require('http').createServer()
app.listen(5000, '75.113.126.31')
Error: listen EADDRNOTAVAIL
People say this error means I'm trying to listen on an IP address that I don't own. But that is my external IP address according to google.
Also, if I omit my IP, it only works when I visit localhost:5000 and 127.0.0.1:5000, visiting 75.113.126.31:5000 doesn't work, even though people say node should listen there too when I don't give a 2nd argument to listen. I also tried listening on IP 0.0.0.0 with no luck accessing it through external IP.
What are the possible causes? I disabled Windows firewall but that didn't help.
Your external IP and your computer's network address often have almost nothing in common. In fact it would be very unusual if they did match.
Normally you bind to 0.0.0.0 if you want your service to be available remotely.
It's also worth noting that if you have some kind of router or firewall you'll need to configure port mapping to get port 5000 to route to your local IP correctly.
ipconfig should show you your actual IP address.
You should also be aware that some routers don't handle mapping internal traffic back to a local IP. Many do, so it's not always a problem, but if it doesn't work that might be the case.
The error message you are getting is correct. I'm going to assume you are on a computer behind a router. That ip address Google is reporting is the ip address assigned to your router not your computer, i.e your computer doesn't own it. You can prove this by running the command ipconfig in a cmd prompt, finding out your eth/wifi ip address, and using that in your app.listen (it'll probably start with 192 or 10), it should work. If you want to make your app public an easier way might be to just forward the port 5000 from your router the computer running the node app. Hope this helps!

Ruby sending packet to a known MAC address

I like to send packet to a device with only MAC address associated to it and also connecting to my local LAN.
Is there anything in ruby / gem library that I can use to perform such task?
I want to do something like tcpreplay but in ruby instead. Thanks!
MACs are the addresses used on OSI layer 2, the package type you are using on this layer are e.g Ethernet frames. IP Sockets live on layer 3/4, thus if you are using an IP socket, you are sending IP packet.
So if you want to send something "to a MAC address", you need to send raw Ethernet frames which need to be understood on the other side. Given the really low level of this stuff, this is rarely what you really want to do.
Instead, you should try to get the proper IP addresses of the remote device in your local network (technically the broadcast domain) with either a broadcast/reply mechanism or with multicast (which is used e.g. by Bonjour). That way you can always use the much more supported IP layer. For that, your device needs to have an IP address of course. You can establish those with mechanisms like DHCP or address auto configuration for IPv6.
As for your question, I'm not aware of any library for Ruby to send raw Ethernet frames. But given you would need to invent a new protocol besides IP anyway (which is hard, really hard), sending the package is probably the least of your concerns.
I suppose there are a couple of approaches. You didn't say whether you wanted to send an IP packet of some kind, and if so you didn't say which IP protocol. (I can tell you want to send an ethernet frame but ... what encapsulated protocol?)
Anyway, you can open a SOCK_RAW with Ruby, something like:
Socket.open(Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_RAW)
Another approach might be to just pick a link-local IP and then establish an IP/MAC mapping in your local ARP cache with something like:
system "arp -s host hw_addr"
Then you could communicate with it using more familiar socket ops using the link-local IP address.
You need to be root for all of these things.

Resources