I have the following code for port forwarding in mac os virtualization
var ipAddr = in_addr()
// 1. Convert String to in_addr
inet_pton(AF_INET, guestIP, &ipAddr)
let status = vmnet_network_configuration_add_port_forwarding_rule(
config,
UInt8(IPPROTO_TCP), // TCP protocol
sa_family_t(AF_INET), // address family
guestPort, // internal port (guest)
externalPort, // external port (host)
&ipAddr // internal address (guest IP)
)
if status == .VMNET_SUCCESS {
print("✅ Port Forwarding set: Mac:\(externalPort) -> VM(\(guestIP)):\(guestPort)")
} else {
print("❌ Port Forwarding failed for \(guestIP): \(status.rawValue)")
}
It is returning success but when i test it it does not work. Is there anything i am doing wrong? Please help me also in fixing this problem. Note: The app runs in sandbox i tried without sandboxing and it does not work either. Please refer to this link https://developer.apple.com/forums/thread/822025?login=true&page=1#884236022 how i am creating the VZVmnetNetworkDeviceAttachment