hashicorp / hashicorp/packer-plugin-virtualbox

Virtual Box with multiple Nics failed to locate the NAT network

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
builder/virtualbox question
Dominant language
Go
Stars
29
Forks
45
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @bax99 as hashicorp/packer#10379. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). The original body of the issue is below._


Hi there,

When installing Kali Linux 2004 with preseed.cfg and having packer configured with only the NAT network interface on VirtualBox, everything is fine.

However, in my case, I need 3 network interfaces to be configured. But with more than one interface, the packer build gets stuck on "Waiting for SSH to become available". If I open the GUI Virtual Machine and log on, I only see 1 Network Interfaces available under Kali Linux, even if three are configured in the json file.

**part of the Json file**

```json
"builders": [
{
"type": "virtualbox-iso",
"boot_command": [
"",
"/install.amd/vmlinuz",
" auto",
" console-setup/ask_detect=false",
" console-setup/layoutcode=us",
" console-setup/modelcode=pc105",
" debconf/frontend=noninteractive",
" debian-installer=en_US",
" fb=false",
" initrd=/install.amd/initrd.gz",
" kbd-chooser/method=us",
" console-keymaps-at/keymap=fr-ch",
" keyboard-configuration/xkb-keymap=fr-ch",
" keyboard-configuration/layout=Swiss french",
" keyboard-configuration/variant=Swiss french",
" locale=fr_CH",
" netcfg/get_domain=hevs",
" netcfg/get_hostname=kali",
" grub-installer/bootdev=/dev/sda",
" noapic",
" interface=enp0s3",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg auto=true priority=critical",
" -- ",
""
],
"boot_wait": "10s",
"disk_size": "{{user `disk_size`}}",
"hard_drive_interface": "sata",
"iso_interface": "sata",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"guest_os_type": "Debian_64",
"headless": "{{ user `headless` }}",
"http_directory": "{{user `http_directory`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_url": "{{user `iso_url`}}",
"memory": "{{ user `memory` }}",
"vboxmanage": [
["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove"],
["modifyvm", "{{.Name}}", "--vrde", "off"],
["modifyvm", "{{.Name}}", "--graphicscontroller", "vmsvga"],
["modifyvm", "{{.Name}}", "--vram", "128"],
["modifyvm", "{{.Name}}", "--accelerate3d", "off"],
["modifyvm", "{{.Name}}", "--usb", "on"],
["modifyvm", "{{.Name}}", "--mouse", "usbtablet"],
["modifyvm", "{{.Name}}", "--audio", "none"],
["modifyvm", "{{.Name}}", "--nictype1", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype2", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype3", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype4", "82540EM"],
["modifyvm", "{{.Name}}", "--clipboard", "bidirectional"],
["modifyvm", "{{.Name}}", "--draganddrop", "bidirectional"],
["modifyvm", "{{.Name}}", "--nic1", "nat"],
["modifyvm", "{{.Name}}", "--natnet1", "default"],
["modifyvm", "{{.Name}}", "--nic2", "intnet"],
["modifyvm", "{{.Name}}", "--intnet1", "intnet"],
["modifyvm", "{{.Name}}", "--nic3", "natnetwork"]
],
"cpus": "{{ user `cpus` }}",
"ssh_username": "adminhevs",
"ssh_password": "************",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
"vm_name": "{{ user `template` }}"
}
],
"post-processors": [
{
"type": "vagrant",
"output": "builds/{{user `box_basename`}}.{{.Provider}}.box"
}
],

```

**Kali nics output**

```
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:b2:a1:ae brd ff:ff:ff:ff:ff:ff

3: eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:98:9c:82 brd ff:ff:ff:ff:ff:ff

4: eth2: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:b9:8c:a3 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.35/24 brd 10.0.2.255 scope global dynamic noprefixroute eth2
```

As shown, eth0 did not get any IP from nat, neither eth1 from intnet. I can set manually IPs with nmcli, but it is not what I expect.

How can we have multiple NICS in the json file and be sure the first one will be taken into account by packer?

Regards

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.