Skip to content

refactor: add support for bridged networking#462

Draft
tenthirtyam wants to merge 1 commit intomainfrom
refactor/bridged-networking
Draft

refactor: add support for bridged networking#462
tenthirtyam wants to merge 1 commit intomainfrom
refactor/bridged-networking

Conversation

@tenthirtyam
Copy link
Collaborator

Summary

Refactors to add support bridged networking.

  • Adds the ability to retrieve the IP address of the guest operating system from VMware Tools.
  • Detects the IP address of the host to use when using bridged networking.
  • Uses the IP address of the guest operating system received from VMware Tools when using bridged networking.
  • Uses the IP address of the guest operating system received from VMware Tools as a fallback for NAT and host-only networking.

Note: The method for NAT and host-only networking may be subsequently refactored to only use the VMware Tools method, but this commit limits the scope to only adding support for bridged networking.

Type

  • fix: Bug Fix
  • feat: Feature or Enhancement
  • docs: Documentation
  • refactor: Refactoring
  • chore: Build, Dependencies, Workflows, etc.
  • other: Other (Please describe.)

Breaking Changes?

  • Yes, there are breaking changes.
  • No, there are no breaking changes.

Tests

  • Tests have been added or updated.
  • Tests have been completed.

Output:

Documentation

  • Documentation has been added or updated.

Issue References

Resolves #397

Release Note

Additional Information

@tenthirtyam tenthirtyam added this to the v2.1.0 milestone Feb 28, 2026
@tenthirtyam tenthirtyam self-assigned this Feb 28, 2026
@tenthirtyam tenthirtyam added the refactor Refactor label Feb 28, 2026
@github-actions github-actions bot added needs-review Needs Review size/l Relative Sizing: Large labels Feb 28, 2026
@tenthirtyam tenthirtyam force-pushed the refactor/bridged-networking branch from 8ada1f5 to 43ada88 Compare February 28, 2026 20:32
@tenthirtyam tenthirtyam marked this pull request as ready for review February 28, 2026 20:34
@tenthirtyam tenthirtyam requested a review from a team as a code owner February 28, 2026 20:34
Copilot AI review requested due to automatic review settings February 28, 2026 20:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors VMware guest/host IP discovery to add bridged-network support, addressing failures when DHCP-based host IP detection is unavailable for bridged networks (Issue #397).

Changes:

  • Use VMware Tools (vmrun getGuestIPAddress) to retrieve the guest IP for bridged networking (and as a fallback for NAT/host-only).
  • Update host IP detection to handle bridged networking without relying on vmnetdhcp config files.
  • Extend the Driver interface and mocks to support VMware Tools-based guest IP retrieval.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
builder/vmware/common/ssh.go Adds bridged logic to prefer VMware Tools guest IP; adds VMware Tools fallback for non-bridged networks.
builder/vmware/common/driver_workstation.go Implements GetGuestIPAddress via vmrun and validates the returned IP.
builder/vmware/common/driver_fusion.go Implements GetGuestIPAddress via vmrun with path normalization and IP validation.
builder/vmware/common/driver.go Extends Driver interface, adds bridged host IP handling + injectable IPFinder, and introduces getHostIPForBridgedNetwork.
builder/vmware/common/driver_parser.go Adjusts DHCP hardware-address parsing constraint in Hardware().
builder/vmware/common/driver_mock.go Adds mock implementation of GetGuestIPAddress.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +730 to +757
func getHostIPForBridgedNetwork() (string, error) {
interfaces, err := net.Interfaces()
if err != nil {
return "", fmt.Errorf("unable to enumerate network interfaces: %s", err)
}

for _, iface := range interfaces {
// Skip loopback and down interfaces.
if iface.Flags&net.FlagLoopback != 0 || iface.Flags&net.FlagUp == 0 {
continue
}

addrs, err := iface.Addrs()
if err != nil {
continue
}

for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok {
if ipv4 := ipnet.IP.To4(); ipv4 != nil {
log.Printf("[INFO] Found host IP for bridged network: %s on interface %s", ipv4.String(), iface.Name)
return ipv4.String(), nil
}
}
}
}

return "", fmt.Errorf("unable to find a non-loopback IPv4 address on any interface")
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getHostIPForBridgedNetwork() returns the first non-loopback IPv4 address across all UP interfaces. On hosts with multiple active interfaces (VPN, Docker/Podman bridges, veths), this can pick an address that is not reachable from the bridged guest, breaking HTTP/communicator connectivity. Consider selecting the interface associated with the default route (or otherwise filtering out virtual/bridge interfaces), or deriving the bridged physical interface from VMware’s networking/bridge mapping configuration before choosing the IP.

Copilot uses AI. Check for mistakes.
@tenthirtyam tenthirtyam marked this pull request as draft February 28, 2026 20:47
@tenthirtyam tenthirtyam force-pushed the refactor/bridged-networking branch 2 times, most recently from b7c69cd to de3f11b Compare February 28, 2026 20:55
Refactors to add support bridged networking.

- Adds the ability to retrieve the IP address of the guest operating system from VMware Tools.
- Detects the IP address of the host to use when using bridged networking.
- Uses the IP address of the guest operating system received from VMware Tools when using bridged networking.
- Uses the IP address of the guest operating system received from VMware Tools as a fallback for NAT and host-only networking.

Note: The method for NAT and host-only networking may be subsequently refactored to only use the VMware Tools method, but this commit limits the scope to only adding support for bridged networking.

Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
@tenthirtyam tenthirtyam force-pushed the refactor/bridged-networking branch from de3f11b to e72ff9c Compare February 28, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Needs Review refactor Refactor size/l Relative Sizing: Large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bridged Networking Error: error detecting host IP: unable to find vmnetdhcp conf file

2 participants