Before I switched from Linux to GhostBSD, my favorite desktop environment was GNOME. One reason for that preference was the handful of unique features GNOME offered. Among them was the ability to disable internet access while keeping the local network active, a task GNOME made simple. I also loved GNOME Files with its special features, like creating bootable flash drives.
Since GNOME isn’t available on GhostBSD, I chose XFCE. While XFCE doesn’t provide the same one‑click toggle, I can still achieve the same result with a few easy steps. Here’s how I disable internet while keeping local networking alive.
How to Find Your Gateway IP
Before you can restore internet access, you’ll need to know your gateway IP (usually your router). Here’s how to find it:
netstat -rn | grep default
You’ll see something like:
default 192.168.1.1 UGSc em0
Again, the number (192.168.1.1) is your gateway.
Tutorial: Disable Internet but Keep LAN
Terminal Method
Open a terminal and run the following commands:
- Disable internet (remove default gateway):
sudo route delete default
- Re‑enable internet (restore default gateway):
sudo route add default <gateway-ip>
Replace<gateway-ip>with your router’s IP (commonly192.168.1.1).
This method cuts off internet access but keeps local traffic intact, so you can still access files or devices on your LAN.
Bonus: Create ZSH Aliases
I use ZSH and to make this even easier, I add aliases to my ~/.zshrc file:
alias netoff='sudo route delete default'
alias neton='sudo route add default 192.168.1.1'
Reload the shell (source ~/.zshrc) and after that, I have two new commands:
netoff→ disable internetneton→ restore internet
Important Note on Shells
The alias examples are written for ZSH, which I personally prefer.
- If you use Bash, the syntax is the same, so you can copy them directly into
~/.bashrc. - If you use Fish shell, the syntax is different. You’ll need to define functions in
~/.config/fish/config.fishinstead of usingalias.
Since I can’t test Fish myself right now, I’m not providing a full example here. But if you need help, just leave a comment and I’ll do my best to point you in the right direction.
Quick Tip! XFCE Panel Option
In the XFCE panel, the network icon offers a right‑click option to disable networking entirely. This shuts down both internet and LAN. For some situations, that’s all I need. But if I want to keep local file sharing or device access, the terminal method above is the better choice.
Security Note
A computer that isn’t connected to the internet is safer than the best firewall. After all, what isn’t connected cannot be seen. By disabling internet while keeping LAN active, you gain control over when your system is visible to the outside world.