Thanks very much Adam. That's given me plenty to go on.

I predict I'll be hacking PowerShell code this weekend...

J


On Fri, 16 Aug 2024 at 18:08, Adam Thorn via Xymon <xymon@xymon.com> wrote:
On 16/08/2024 08:54, Jeremy Laidman wrote:
> Hi
>
> Can anyone tell me if there's a way to have XymonPSClient bind to a
> specific IP address (or NIC) when connecting to the Xymon server? I'm
> having the client installed onto some dual-homed hosts, where the NIC
> with the default route is used for web services and a secondary NIC is
> used for management traffic. I need the Xymon client to use the
> management NIC IP address so that it routes via the management traffic
> path. I'd rather not add a static route onto the host.

I thik this is the critical line:

https://github.com/svn2github/xymon/blob/master/sandbox/WinPSClient/xymonsend.ps1#L26C1-L26C54

Checking the docs for TcpClient,

https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.tcpclient.-ctor?view=net-8.0#system-net-sockets-tcpclient-ctor(system-net-ipendpoint)

"If you create a TcpClient using any other constructor, the underlying
service provider will assign the most appropriate local IP address and
port number."

(you might have to ask MS how they decide what is "most appropriate" .. !)

Quoting from https://stackoverflow.com/a/2016029, calling the
constructor with arguments like

TcpClient c=new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 0);

would force the TcpClient to use the specified local address.

That looks to me like the answer is probably "not without a bunch of
modifications"

Adam
_______________________________________________
Xymon mailing list -- xymon@xymon.com
To unsubscribe send an email to xymon-leave@xymon.com