Forum Discussion

abhishekgupta's avatar
abhishekgupta
Icon for Microsoft rankMicrosoft
Oct 24, 2023

.net tcpip socket bind on a VRF

.netcore is there a way to listen and bind on a particular vrf in linux, i want to listen on 0.0.0.0:443 but this goes to default vrf.

1 Reply

  • ArtemiyMoroz's avatar
    ArtemiyMoroz
    Copper Contributor

    abhishekgupta hi there.

    Since binding to VRF is Linux-specific stuff, I would suggest to call library functions using p/invoke

    you will need to call 

    setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1);

    but in c# using https://iq.direct/blog/424-how-to-call-p-invoke-in-c-on-linux.html

Resources