VyOS Homelab on Windows (Part 2 of N): Attaching the Host-Only Adapter to VyOS and SSHing a Python Script from PowerShell to Rename It
This follows on from my previous blog: 'How I finally pinged and SSHed to the VyOS in Oracle VM from powershell'
In that last blog I found a Host-Only Ethernet Adapter that Windows would actually accept without blocking it. If you are stuck with no ping, read that one first.
Today was different. Today was about attaching that already-working adapter to the VyOS router itself, and proving I can send a Python script from PowerShell to configure it. The test for today was to rename the router to VyOS-R1.
The bigger goal for this homelab is to test if I can SSH an OSPF config to an ISP router in Oracle VM later. Today's rename test proves the method will work.
1. What I Did Today - Attach The Adapter
The adapter Windows accepted is VirtualBox Host-Only Ethernet Adapter.
Steps:
- Power off VyOS VM
- VirtualBox > VyOS VM > Settings > Network
- Adapter 1: Enabled, Attached to: Host-only Adapter, Name: VirtualBox Host-Only Ethernet Adapter, Promiscuous Mode: Allow All VMs, Cable Connected: checked
- Adapter 2,3,4: Disabled for today
Boot VyOS, login: vyos / vyos
Then give eth0 an IP on that host-only network:
configure
set interfaces ethernet eth0 address 192.168.56.101/24
set service ssh port 22
commit
save
exit
2. Prove PowerShell Can SSH To The Attached Adapter
In PowerShell you need to see PS> not >>>.
Run:
ping 192.168.56.101
ssh vyos@192.168.56.101
Password is vyos.
If you get a VyOS prompt, the adapter is now truly attached to the router. I typed exit to leave SSH after.
. The Python Script I Ran Today - Renaming Test
In PowerShell:
notepad name_router.py
Paste this:
from netmiko import ConnectHandler
router = {
'device_type': 'vyos',
'host': '192.168.56.101',
'username': 'vyos',
'password': 'vyos',
}
conn = ConnectHandler(**router)
conn.send_config_set(['set system host-name VyOS-R1', 'commit', 'save'])
print(conn.send_command('show system host-name'))
conn.disconnect()
Then install and run:
pip install netmiko
python .\name_router.py
The script should print VyOS-R1.
5. How I Knew It Worked
Weird part: When I SSHed with ssh vyos@192.168.56.101 it already said vyos@VyOS-R1 which is new name.
But in the Oracle VM console window it still said vyos@vyos.
Reason: The console window is an old login session from before the rename. Fix: type exit in that VM window, login again with vyos / vyos, now it says vyos@VyOS-R1.
That moment = 🎉 success.
Today proved: Host-only adapter is attached to router, PowerShell can SSH to router, Python script from PowerShell can change router config.
Why This Matters For OSPF
If set system host-name works via Python, then set protocols ospf will work the same way. Today was the plumbing test for future OSPF push to ISP.
What Is Next
Part 3: Making 2 Clones and Switching On All 4 Adapters in Each VyOS.
Plan for next lab:
- Clone VyOS-R1 to create 2 more routers
- On each router, Adapter 1 = Host-Only (the adapter we found in last blog and attached today) for management from Windows
- Switch on Adapter 2, 3, 4 as Internal Networks for router to router links
- Make all 4 adapters up and pingable on each router
Then after that we can start pushing OSPF configs.
Previous blog: 'How I finally pinged and SSHed to the VyOS in Oracle VM from powershell' - about finding the adapter Windows will accept.
This blog: About attaching that adapter and proving Python SSH rename works.