Skip to content

Instantly share code, notes, and snippets.

@bufadu
Last active October 6, 2022 10:55
Show Gist options
  • Save bufadu/0487b2002415bde324a2dba197647087 to your computer and use it in GitHub Desktop.
Save bufadu/0487b2002415bde324a2dba197647087 to your computer and use it in GitHub Desktop.
How to install vyos on scaleway instance.

How to install VyOS on Scaleway virtual instance.

VyOS

VyOS is an open source network operating system based on Debian GNU/Linux. It provides a free routing platform that competes directly with other commercially available solutions from well known network providers.[W]

The entire configuration is managed through a CLI that mimic the JunOS cli behaviour. (And I really like that :)

It embeds tons of network features. Most useful with a scaleway deployment will probably be :

  • VPN: Ipsec, Wireguard, Openvpn..
  • Routing protocols: BGP, OSPF..
  • Firewalling
  • etc.

With the upcoming private network, it will be a good candidate to be your NAT gateway/VPN gateway/Routing instance.

Installation

VyOS is not (yet ?) available on Scaleway's OS Images or InstantApps thus we need to install it directly from the official ISO image.

Start the new virtual instance

For this tutorial, I choose to use a DEV1-S and I have to admit that I haven't tested this procedure on an other type of instance.

Create a new virtual instance like:

  1. Operating system: whatever you want, we will never use it.
  2. Availability zone: up to you.
  3. Select an instance: DEV1-S
  4. Add volume: all the trick is here, you need to add a new block storage. The purpose of this is to have a spare block storage on which we will 'burn' the ISO install image.

volumes

Once the instance created and launched go to the 'Advanced Settings' tab and choose 'Rescue image'. Reboot the instance and wait for it to be accessible via ssh.

"Burn" ISO image and make it bootable

Log on the instance (booted in rescue mode): ssh root@[your_instance_ip_address]

Type lsblk command and you should get something like:

NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda       8:0    0 23.3G  0 disk 
vda     254:0    0 18.6G  0 disk 
├─vda1  254:1    0 18.5G  0 part /
└─vda15 254:15   0  100M  0 part /boot/efi

Device vda is your local block storage. sda is the second block storage we added in previous step.

Copy the ISO image on /dev/sda:

curl https://downloads.vyos.io/rolling/current/amd64/vyos-rolling-latest.iso > /dev/sda

Then, erase the first few (mega)bytes of /dev/vda to make it unbootable:

dd if=/dev/zero of=/dev/vda bs=1M count=100 ; sync

The instance is now ready to boot on the ISO image.

Start VyOS LiveCD

Reboot the instance through Instance information tab and then quickly launch the console (the grey button on the right of instance information). Wait few minutes* and you should see the VyOS LiveCD bootloader (grub) :

grub

*If nothing happen after several minutes (ie. the console stay blank), stop, close the console, start the instance and launch the console again.

Log in VyOS with username vyos and vyos.

logged in

Minimal configuration

If you do not know how the VyOS (or Ubiquiti EdgeOS or Vyatta) command line interface works, here is the doc you really should read : https://docs.vyos.io/en/latest/cli.html

VyOS comes with no configuration. Let set the minimal to have a reachable VyOS instance.

First, type configure to enter in configuration mode and execute the following commands:

Configure eth0

set interfaces ethernet eth0 address 'dhcp'

Configure ssh

set service ssh port 22

Commit and save

commit

save

Note: Unlike JunOS, with VyOS when you commit configuration, it's still volatile. You need to explicitly save it to make it persistent.

Use exit to leave configuration mode.

Installation

Type install image.

Nothing hard here, just follow the installation steps and don't forget to select vda as target device.

Here is my full installation trace, if that can help someone :

vyos@vyos:~$ install image
Welcome to the VyOS install program.  This script
will walk you through the process of installing the
VyOS image to a local hard drive.
Would you like to continue? (Yes/No) [Yes]: 
Probing drives: OK
Looking for pre-existing RAID groups...none found.
The VyOS image will require a minimum 2000MB root.
Would you like me to try to partition a drive automatically
or would you rather partition it manually with parted?  If
you have already setup your partitions, you may skip this step

Partition (Auto/Parted/Skip) [Auto]: 

I found the following drives on your system:
 vda    20000MB
 sda    24999MB


Install the image on? [vda]:

This will destroy all data on /dev/vda.
Continue? (Yes/No) [No]: Yes

How big of a root partition should I create? (2000MB - 20000MB) [20000]MB: 

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!

Invalid partition data!
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Creating new GPT entries.
The operation has completed successfully.
Creating filesystem on /dev/vda3: OK
Done!
Mounting /dev/vda3...
What would you like to name this image? [1.3-rolling-202005051136]: 
OK.  This image will be named: 1.3-rolling-202005051136
Copying squashfs image...
Copying kernel and initrd images...
Done!
I found the following configuration files:
    /opt/vyatta/etc/config/config.boot
    /opt/vyatta/etc/config.boot.default
Which one should I copy to vda? [/opt/vyatta/etc/config/config.boot]: 

Copying /opt/vyatta/etc/config/config.boot to vda.
Enter password for administrator account
Enter password for user 'vyos':
Retype password for user 'vyos':
I need to install the GRUB boot loader.
I found the following drives on your system:
 vda    20000MB
 sda    24999MB


Which drive should GRUB modify the boot partition on? [vda]:

Setting up grub: OK
Done!

Wooh ! VyOS is now installed on your instance.

Type poweroff to .. hum.. shut down the system.

Detach and delete block storage

In scaleway console, stop the instance (powering off the system is not enough). Once instance archived, in the 'Attached Volumes' tab, locate the block storage and detach it. Then Delete it.

Start your instance again.

Use ssh vyos@[instance_ip] and enjoy your new shiny router !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment