I want to configure an interface for the virtual box, which is installed within my ubuntu machine. When i create it manually it works:
vboxmanage hostonlyif create
vboxmanage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
by checking ifconfig, It is there :
I want to make these changes survive a reboot and set automatically during system startup.For that what i did is:
sudo mkdir /opt/systemd/
then
sudo mkdir /opt/systemd/
then
sudo nano /opt/systemd/vboxhostonly
and copy the following code into the file:
#!/bin/bash
vboxmanage hostonlyif create
vboxmanage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
then Ctrl + X to exit , Y to save and enter to write file.
Then I make the file executable
cd /opt/systemd/ then sudo chmod a+x vboxhostonly
the I create a service so
sudo touch /etc/systemd/system/vboxhostonlynic.service
Then I Edit the file by typing sudo nano /etc/systemd/system/vboxhostonlynic.service
and then typing in:
Description=Setup VirtualBox Hostonly Adapter
After=vboxdrv.service
[Service]
Type=oneshot
ExecStart=/opt/systemd/vboxhostonly
[Install]
WantedBy=multi-user.target
then Ctrl + X to exit , Y to save and enter to write file.
Now to install the service and ensure it loads at boot time I type:
systemctl daemon-reload
systemctl enable vboxhostonlynic.service
But when i reboot the machine the interface is not there, any help would be appreciated?