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
Wow. that worked.
Cool.
The good news is that this confirms a theory that was raised during my discussion of your issues with the vmnet team. The bad news is that this is a known limitation of vmnet (FB7731708).
We hope to fix it sooner rather than later, but I don’t have any concrete timeline to share.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"