THE CATCH-22
PNETLab has two login modes: online and offline. Online mode requires PNETLab's servers to authenticate you. Offline mode uses a local account and doesn't need internet at all. Sounds great until you realize that enabling offline mode requires you to first log in via online mode.
So when PNETLab's servers go down (and they do), you're locked out of your own machine. Your labs are right there. Your images are right there. Your vQFX nodes are probably wondering where you went. But the login page needs to phone home to a server that's currently taking a nap, and the offline option you never bothered to enable is sitting there grayed out, judging you.
I ran into this recently. pnetlab.com was completely unresponsive, and my box had online mode as the only option. The web UI was very helpful about it, too:
OFFLINE Mode is disabled. If you want to using OFFLINE mode, login by ONLINE account then active OFFLINE mode.Thanks. The grammar is rough but the message is clear: you're not getting in.
THE OBVIOUS FIX THAT DOESN'T QUITE WORK
PNETLab supports switching modes from the CLI. SSH into the box and run:
mode default offlineThis updates the default login mode in the database. But when I refreshed the web UI, same error. The command only sets which mode is the default, it doesn't actually enable offline mode if it was never activated through the GUI in the first place. Time to go deeper.
INTO THE DATABASE
The web UI is locked and the CLI command didn't cut it, but PNETLab is just an Ubuntu VM running MySQL. Connect to the database:
mysql -u pnetlab -ppnetlab pnetlab_dbThe system mode settings live in the control table. Let's see what columns we're working with first, because different PNETLab versions have slightly different schemas:
DESCRIBE control;+---------------+--------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+---------------+--------------+------+-----+---------+-------+| control_name | varchar(150) | NO | PRI | NULL | || control_value | text | YES | | NULL | |+---------------+--------------+------+-----+---------+-------+Some guides online reference columns called name and value, but on my version (5.3.x) they're control_name and control_value. If you copy queries from a wiki and get Unknown column 'name' in 'where clause', that's why.
FINDING THE MISSING PIECE
Now let's check what mode-related entries actually exist:
SELECT * FROM control WHERE control_name LIKE '%mode%';+-------------------+---------------+| control_name | control_value |+-------------------+---------------+| ctrl_default_mode | offline || ctrl_online_mode | 1 |+-------------------+---------------+Two rows. The ctrl_default_mode shows offline because I had already tried the CLI command mode default offline from the PNETLab console. That command updates the default mode value in the database, but it doesn't actually create the ctrl_offline_mode row if it doesn't exist. So the system thinks it should default to offline, but offline mode itself was never enabled as a feature. The fix is simple, insert the missing row:
INSERT INTO control VALUES ('ctrl_offline_mode', '1');That's half the problem. The other half is that offline mode uses its own local user accounts, and if you've only ever logged in online, there might not be one.
CREATING THE OFFLINE ADMIN ACCOUNT
Check the users table:
SELECT username FROM users;+---------------------------------+| username |+---------------------------------+| your_online_account |+---------------------------------+There's only one user in the table, and it's the online account. Offline mode needs a local account to authenticate against, so we need to create one. But before blindly inserting, check the schema because the column count matters:
DESCRIBE users;On my version, it's 23 columns. The important ones for a working offline admin account are pod (the primary key, auto-increment), username, password, expiration, role, offline, and user_status. Everything else can be NULL.
The default offline password is pnet, and PNETLab stores it as a SHA-256 hash. Here's the insert:
INSERT INTO users (pod, username, email, expiration, password, role, offline, user_status)VALUES (2, 'admin', NULL, -1,'fcfcbba4e322bb69d53fe0f8a2b03d7f3c37ee3fb3d51864785c899aaeaaeb5d','admin', 1, 1);One thing to watch: pod is the primary key and your existing online account already has pod=1. If you try to insert with pod=1, you'll get a duplicate entry error. Just use the next available number.
The expiration=-1 means the account never expires, and offline=1 flags it as a local account. The hash is standard SHA-256 for the string pnet.
VERIFY AND LOG IN
Exit MySQL, open your browser, navigate to the PNETLab IP. You should now see the offline login option. Credentials:
Username: adminPassword: pnetIf you want to double-check everything took effect, you can verify from MySQL before closing out:
SELECT control_name, control_value FROM control WHERE control_name LIKE '%mode%';+-------------------+---------------+| control_name | control_value |+-------------------+---------------+| ctrl_default_mode | offline || ctrl_offline_mode | 1 || ctrl_online_mode | 1 |+-------------------+---------------+Three rows now. Both modes enabled, default set to offline. That's the correct state.
THAT'S IT!
The whole thing is two INSERT statements once you know where to look. The frustrating part isn't the fix, it's that PNETLab's architecture makes offline mode depend on an online login to activate. If their servers are down and you never toggled that switch, the web UI gives you absolutely no way out.
So if you're reading this proactively and your PNETLab online login still works: go to System > System Mode and enable offline mode right now. Future you will be grateful when the servers inevitably go down at 11 PM on a Saturday and all you wanted was to run one quick OSPF lab before bed. Don't be the person running INSERT statements on a production database with shaking hands because they forgot to click a checkbox six months ago. I was that person, and I was one wrong query away from restoring from a backup. Again.
Thanks for reading. Change the default password after you log in.
