DEV Community

Cover image for Part 2: Friday 13th Didn't Win - From Typo to Full/DR
Melissa
Melissa

Posted on

Part 2: Friday 13th Didn't Win - From Typo to Full/DR

Part 2: Friday 13th Didn't Win - From Typo to Full/DR

EDITOR'S NOTE ON DATES:
Troubleshooting in this post was done live on Friday 13th, despite the risks. I'm not publishing it today because I need to read it again first to fact-check, so that explains why the publish date will be different.


WHERE PART 1 LEFT US:
At the end of Part 1, OSPF was silent. show ip ospf was empty. My first automation script had worked, but with the wrong router-ids and a messy lo interface table. As I said at the time: I left the lo IDs there on purpose to see them. First automation, you want to see proof.

THE DELETE SCRIPT AND WHY I USED IT:
Before I can fix, I have to clean. VyOS won't let you just overwrite some OSPF values cleanly if you have a half-config.

So I wrote delete_OSPF12NOV.py. The typo in the filename that PowerShell hated was my Friday 13th tax.

The script does:
configure
delete protocols ospf
delete interfaces loopback lo address 1.1.1.1/32 etc
commit
save
exit

Why? Because I want to start from zero and then add back the correct router-ids: 1.1.1.1, 2.2.2.2, 3.3.3.3. And I want those IDs to actually show up on lo so I can see them in show interfaces.

PowerShell lesson: python .\delete_OSPF12NOV.py - and double check filename spelling. File not found = typo.

import getpass
from netmiko import ConnectHandler

routers = ["192.168.56.101", "192.168.56.102", "192.168.56.103"]
username = input("VyOS username: ")
password = getpass.getpass("VyOS password: ")

delete_commands = [
"configure",
"delete protocols ospf",
"delete interfaces loopback lo address",
"commit",
"save",
"exit"
]

for ip in routers:
print(f"\n--- Deleting OSPF on {ip} ---")
device = {
"device_type": "vyos",
"host": ip,
"username": username,
"password": password,
}
try:
conn = ConnectHandler(**device)
output = conn.send_config_set(delete_commands)
print(output)
conn.disconnect()
except Exception as e:
print(f"BUG on {ip}: {e}")

THE UPDATED PYTHON SCRIPT:
This is the version that finally worked. Note the change from 10.0.0.x to real router-ids, and the explicit loopback address so the ID is visible on lo.

import getpass
from netmiko import ConnectHandler

routers = [
{"host": "192.168.56.101", "router_id": "1.1.1.1", "lo_ip": "1.1.1.1/32"},
{"host": "192.168.56.102", "router_id": "2.2.2.2", "lo_ip": "2.2.2.2/32"},
{"host": "192.168.56.103", "router_id": "3.3.3.3", "lo_ip": "3.3.3.3/32"},
]

username = input("VyOS username: ")
password = getpass.getpass("VyOS password: ")

for r in routers:
print(f"\n--- {r['host']} ---")
device = {
"device_type": "vyos",
"host": r['host'],
"username": username,
"password": password,
}
try:
conn = ConnectHandler(**device)
cmds = [
"configure",
f"set interfaces loopback lo address {r['lo_ip']}",
f"set protocols ospf area 0 network 192.168.56.0/24",
f"set protocols ospf parameters router-id {r['router_id']}",
"commit",
"save",
"exit"
]
output = conn.send_config_set(cmds)
print(output)
conn.disconnect()
except Exception as e:
print(f"BUG on {r['host']}: {e}")

print("\nDone - now check R1: show interfaces | show ip ospf neighbor")

THE RESULT OF show ip ospf neighbor:

First, the lesson: it's ospf, not OSPF. Case sensitive. And it's neighbor, not neighbors.

I ran:
vyos@VyOS-R1:~$ show ip ospf neighbors
-> Invalid command: show ip ospf [neighbors]

Then:
vyos@VyOS-R1:~$ show ip ospf neighbor

And I have neighbors! Proof from R1:

Neighbor ID Pri State Up Time Dead Time Address Interface
2.2.2.2 1 Full/Backup 17m30s 31.154s 192.168.56.102 eth0:192.168.56.101
3.3.3.3 1 Full/DR 17m44s 35.845s 192.168.56.103 eth0:192.168.56.101

Translation:
R1 -> R2 Full/Backup
R1 -> R3 Full/DR

That is OSPF Area 0 fully formed. No console clicks. Just Python from Windows to three VyOS routers.

CONCLUSION:
Status at end of Part 2: From "OSPF is not enabled" to "Full/DR". That weary feeling of expecting more problems? Friday 13th didn't win.ontent

Top comments (0)