UDP out cant set host IP

Node-Red Version
3.0.2
Node Version
V18.16.1 (MACOS)
Electron Version
No response
Platform
MACOS12.1
Architecture
x64
My PC has multiple IP addresses, 192.168.8.47 and 192.168.0.17.
I want to use UDP with IP 192.168.0.17 to communicate with 192.168.0.7,I set IP priority,but it doesn't work.
And I set UDP out msg.ip msg.port and other attributes,but it doesn't work.
And I search form and no answers.
So,dear friends,How could I use 192.168.0.17 to do UDP work?

[{"id":"3d6c506f0fde9b2d","type":"udp in","z":"1ff159cb2e02fd26","name":"","iface":"192.168.0.17","port":"48899","ipv":"udp4","multicast":"true","group":"255.255.255.255","datatype":"utf8","x":180,"y":2980,"wires":[["58afb0fd8c39eb0f"]]},{"id":"19b9842366545bec","type":"function","z":"1ff159cb2e02fd26","name":"发送","func":"msg.payload='www.usr.cn'\n// msg.fromip = '255.255.255.255:48899'\n// msg.host = '255.255.255.255'\n// msg.ip = '192.168.0.7'\n// msg.port='48899'\n// msg.des='diy'\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":2920,"wires":[["25a4b14ff2fc0433"]]},{"id":"7e62fce750e989dc","type":"inject","z":"1ff159cb2e02fd26","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":2920,"wires":[["19b9842366545bec"]]},{"id":"9727acd08e975d94","type":"debug","z":"1ff159cb2e02fd26","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":2980,"wires":[]},{"id":"58afb0fd8c39eb0f","type":"function","z":"1ff159cb2e02fd26","name":"接收","func":"msg.payload=msg.payload.toString()\nnode.warn(\"@@@串口参数 msg:\" + JSON.stringify(msg, null, 6))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":2980,"wires":[["9727acd08e975d94"]]},{"id":"25a4b14ff2fc0433","type":"udp out","z":"1ff159cb2e02fd26","name":"","addr":"255.255.255.255","iface":"192.168.0.17","port":"48899","ipv":"udp4","outport":"6666","base64":false,"multicast":"multi","x":540,"y":2920,"wires":[]},{"id":"5ccb81f2d6d6901d","type":"comment","z":"1ff159cb2e02fd26","name":"This machine has multiple IP addresses, 192.168.8.47 and 192.168.0.17.","info":"","x":320,"y":3060,"wires":[]},{"id":"3b750831059fdcf7","type":"comment","z":"1ff159cb2e02fd26","name":"I want to use UDP with IP 192.168.0.17 to communite with 192.168.0.7,I set IP priority,but it doesn't work","info":"","x":420,"y":3100,"wires":[]},{"id":"f654dda228bd8507","type":"comment","z":"1ff159cb2e02fd26","name":"How could I use 192.168.0.17 to do UDP work?","info":"","x":240,"y":3140,"wires":[]}]

This isn't really a node-red issue. I think you need to set a Route on your PC to tell the OS which interface to use when accessing 192.168.0.7

Thanks for reply.
Could Set UDP function to achieve the goal?
Because In some cases, it is not possible to set up a route and there are many differences between different operating systems.

I don't believe so. Network routing is up to the OS.

@Colin :grin:



Thank you for your answer. Hello friend.
This is a commonly used tool software for network debugging, which can be used for UDP communication. As the host has many network interfaces, when using it for UDP communication, a specified IP can be selected for communication.
Due to the production environment, we try not to adjust the network information of the original industrial host as much as possible, but only change some additional hardware, such as serial servers. This can convert serial ports, such as 485, into network ports. When configuring the serial server, the serial server itself supports UDP modification, so UDP needs to be used. However, the host has multiple network ports, and UDP can only be established on the same network segment as the serial server.
So, when establishing UDP communication, we need to choose the specified network interface IP.
This is the reason for this problem.

In order to set the pi using msg.ip you need to leave the field blank in the config panel. The screen shot you posted seems to have it set to 255.255.255.255

@dceejay
Thank you for your answer.I tried leaving it blank and using parameters, but it still doesn't work

[{"id":"e326bce4db79551c","type":"inject","z":"1ff159cb2e02fd26","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":3220,"wires":[["d56042b2d83ea861"]]},{"id":"d56042b2d83ea861","type":"function","z":"1ff159cb2e02fd26","name":"发送","func":"msg.payload='www.usr.cn'\nmsg.fromip = '255.255.255.255'\n// msg.host = '255.255.255.255'\nmsg.ip = '192.168.0.17'\nmsg.port='48899'\n// msg.des='diy'\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":3220,"wires":[["019b4c29d1f1830a"]]},{"id":"019b4c29d1f1830a","type":"udp out","z":"1ff159cb2e02fd26","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":410,"y":3220,"wires":[]},{"id":"1e512e7afacd515f","type":"udp in","z":"1ff159cb2e02fd26","name":"","iface":"192.168.0.17","port":"48899","ipv":"udp4","multicast":"true","group":"255.255.255.255","datatype":"utf8","x":180,"y":3260,"wires":[["248a869ab59d1589"]]},{"id":"36924829da80582e","type":"debug","z":"1ff159cb2e02fd26","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":3260,"wires":[]},{"id":"248a869ab59d1589","type":"function","z":"1ff159cb2e02fd26","name":"接收","func":"msg.payload=msg.payload.toString()\nnode.warn(\"@@@串口参数 msg:\" + JSON.stringify(msg, null, 6))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":3260,"wires":[["36924829da80582e"]]}]

I'm not quite sure what you are trying to do - you are sending to a specific IP address - but then listening on a multicast address to a group that are not usually specified like that. Also the same device does not usually receive it's own multicast messages so even if you send them multicast you will not receive them back in order to help stop loops. etc.

Here is a simple standard udp out and in on my local machine ip

[{"id":"15901f16b6cc68a8","type":"udp in","z":"3ab54eb0381845c3","name":"","iface":"","port":"48899","ipv":"udp4","multicast":"false","group":"","datatype":"utf8","x":140,"y":200,"wires":[["868794abc3e466b5"]]},{"id":"4e795e7e0514ee9c","type":"udp out","z":"3ab54eb0381845c3","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":430,"y":100,"wires":[]},{"id":"992496fc69e40b80","type":"inject","z":"3ab54eb0381845c3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":100,"wires":[["d91822546a0f74b3"]]},{"id":"d91822546a0f74b3","type":"function","z":"3ab54eb0381845c3","name":"function 1","func":"msg.ip = \"192.168.1.193\";\nmsg.port = 48899;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":100,"wires":[["4e795e7e0514ee9c"]]},{"id":"868794abc3e466b5","type":"debug","z":"3ab54eb0381845c3","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":340,"y":200,"wires":[]}]

@dceejay
Thank you for your response.
The reason for this operation is that a serial server uses UDP to configure its parameters. In order to dynamically use UDP for parameter configuration in node red.
I am also using UDP for the first time. When performing specific requirements, the first step is to configure the same network segment as the serial server, then send a broadcast and a specific string, and the serial server will reply upon receiving it. After receiving the reply, the operator sends specific configuration information to complete the final configuration.
If both parties are not on the same IP end, the serial server will not reply to messages.