如何使用 vboxmange 工具修复 VirtualBox redhat-7 eth0 ONBOOT=no 连接问题? [英] How to fix VirtualBox redhat-7 eth0 ONBOOT=no connectivity issue with vboxmange tools?

查看:60
本文介绍了如何使用 vboxmange 工具修复 VirtualBox redhat-7 eth0 ONBOOT=no 连接问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建带有打包程序的 virtualbox redhat box,模板附在下面.一切都很好,除了在创建并重新启动主机时,eth0 网络适配器不会启动,因为它是在/etc/sysconfig/network-scripts 中使用 ONBOOT=no 创建的.但是,如果我打开盒子的 UI 并手动触发 ifup eth0,它开始正常,ssh 变得可用并且该过程按预期完成.但是,我需要在 jenkins 管道中使用它,因此没有人可以手动启动网络接口.问题是,是否有任何方法可以使用 virtualbox manage 命令将网络适配器的 ONBOOT 选项更改为 yes,或者以某种方式触发 ifup eth0 命令.任何一个选项都可以解决问题.

I am creating virtualbox redhat box with packer with the template attached below. Everything is fine except that when the host is created and rebooted, the eth0 network adapter does not start as it is created with ONBOOT=no in /etc/sysconfig/network-scripts. However, if I open the UI of the box and manually trigger ifup eth0, it starts fine, ssh becomes available and the process completes as expected. However, I need to use it in a jenkins pipeline so there is no option someone can go and start the network interface manually. The question, is there any way to change the ONBOOT option to yes for the network adapter with virtualbox manage commands, or trigger the ifup eth0 command somehow. Either option may solve the problem.

  {
  "variables": {
    "build_base": ".",
    "isref_machine":"create-ova-caf",
    "build_name":"virtual-box-jenkins",
    "output_name":"packer-virtual-box",
    "disk_size":"40000",
    "ram":"1024",
    "disk_adapter":"ide"
  },  
  "builders":[
        {   
          "name": "{{user `build_name`}}",
          "type": "virtualbox-iso",
          "guest_os_type": "Other_64",
          "iso_url": "rhelis74_1710051533.iso",
          "iso_checksum": "",
          "iso_checksum_type": "none",
          "hard_drive_interface":"{{user `disk_adapter`}}",
          "ssh_username": "root",
          "ssh_password": "Secret1.0",
          "shutdown_command": "shutdown -P now",
          "guest_additions_mode":"disable",
          "boot_wait": "3s",
          "boot_command": [ "auto<enter>"],
          "ssh_timeout": "40m",
          "headless":
          "true",
          "vm_name": "{{user `output_name`}}",
                    "disk_size": "{{user `disk_size`}}",
          "output_directory":"{{user `build_base`}}/output-{{build_name}}",
          "format": "ovf",
          "vrdp_bind_address": "0.0.0.0",
          "vboxmanage": [
            ["modifyvm", "{{.Name}}","--nictype1","virtio"],
            ["modifyvm", "{{.Name}}","--memory","{{ user `ram`}}"]
          ],
          "skip_export":true,
          "keep_registered": true
        }   
  ],  
  "provisioners": [
    {
      "type":"shell",
      "inline": ["ls"]

    }
  ]

}

推荐答案

要将网络接口启动设置更改为 onboot=yes,我们需要创建一个 anaconda kickstart 脚本或从现有机器复制一个并更改其中的配置并将其作为

To change the network interface boot settings to onboot=yes, we need to create an anaconda kickstart script or copy one from an existing machine and change the configurations in it and pass it as

 "boot_command": [ "<esc><wait>",
        "vmlinuz initrd=initrd.img net.ifnames=0 biosdevname=0 ",
        "ks=hd:fd0:/anaconda-ks.cfg",
        "<enter>"
  ],

在anaconda文件中

and in anaconda file

network  --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto --activate

这篇关于如何使用 vboxmange 工具修复 VirtualBox redhat-7 eth0 ONBOOT=no 连接问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆