NOTE: I originally published this page in 2018; instructions may now be out of date.
The Juniper vMX product doesn’t include any init scripts or systemd unit files. You cannot also just set the VM’s to autostart with virsh since the VM’s are added and started with the
vmx.sh shell script that Juniper provides.
SysV init (eg. Ubuntu 14.04)
You will need to add your own init script.
- Download a copy of the init script from here.
- Edit the init script and fix the
DIRvariable. In my case I am deploying Juniper vMX 17.4R1 which is installed in
/home/vMX-17.4R1/. The trailing
/must be added.
- Copy the modified init script to
- Make the init script executable:
chmod +x /etc/init.d/vmx
- Enable the script to start on boot:
update-rc.d vmx defaults update-rc.d vmx enableTest to make sure that the status output works, it will discover if you have any errors with the script before you reboot:
You can now reboot the host to verify that it starts on boot correctly.
systemd (eg. CentOS 7, Ubuntu 16.04)
I am using CentOS 7.4 which means that a systemd service file is used instead of the init script like for Ubuntu 14.04. If you are using this systemd service file with other distributions you may need to correct the
PATH variable to suite your environment – on CentOS 7.4 Python 2.7 must be used to start the vMX.
Note: To get the systemd service file working on CentOS I found that SELINUX needs to be disabled. I didn’t have time to debug it further to find out what needs to be allowed in order to leave it running.
- Download a copy of the systemd service file from here
- Edit the file and set the correct path for
WorkingDirectory. This path must contain the
vmx.shscript. On CentOS 7 you will need to uncomment the
PATHenvironment variable as well.
- Copy the modified service file to
- Reload systemd daemons to pick up the new service:
- Check the status of the service to make sure that there is no error (eg. invalid syntax for the service file):
systemctl status vmx.service
- Enable the service so that it will be started on boot:
systemctl enable vmx
SELINUX needs to be disabled otherwise the systemd unit will fail. Run this to disable SELINUX:
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
After changing the SELINUX policy reboot the server and the vMX should start automatically.
Errors like this are caused by the SELINUX policy blocking it:
vmx_service.sh: Find configured management interface..............vlan51 vmx_service.sh: Find existing management gateway..................vlan50 vmx_service.sh: Check if vlan51 is already enslaved to br-ext.....[No] vmx_service.sh: Gateway interface needs change....................[No] vmx_service.sh: Flush vlan51......................................[OK] vmx_service.sh: Bind vlan51 to br-ext.............................[Failed] vmx_service.sh: bridge br-ext does not exist! vmx_service.sh: Log file........................................../dev/null vmx_service.sh: ================================================== vmx_service.sh: Aborted!. 1 error(s) and 0 warning(s) vmx_service.sh: ================================================== systemd: vmx.service: main process exited, code=exited, status=2/INVALIDARGUMENT systemd: Failed to start Juniper vMX Router.