Automated Network Configuration Utility for Windows and Linux
NetSwitch is a lightweight utility that streamlines the process of switching between Dynamic (Home) and Static (Lab) network environments. Designed for developers, network engineers, and students, it eliminates repetitive network configuration commands and makes transitions between network types quick and predictable on both Windows and Linux.
In complex network environments, switching between DHCP (Dynamic Host Configuration Protocol) and Static IP configurations can be tedious. NetSwitch abstracts this complexity into two simple, user-friendly scripts.
| Feature | HOME Network | LAB Network |
|---|---|---|
| Protocol | DHCP (Automatic) | Static IP |
| IP Address | Assigned by Router | 10.2.11.80 |
| Subnet Mask | Auto-assigned | 255.255.252.0 |
| Gateway | Auto-assigned | 10.2.8.1 |
| DNS | Auto-assigned | 8.8.8.8 (Google DNS) |
| Use Case | Home, Office, Public Wi-Fi | Testing, Labs, Corporate Networks |
NetSwitch operates as a lightweight batch automation tool. It uses the Windows netsh API to modify network stack settings. The following diagram illustrates the execution flow:
graph TD
User[User Double-Clicks Script] -->|Triggers| AdminCheck{Admin Privileges?}
AdminCheck -->|No| RunError[❌ Access Denied]
AdminCheck -->|Yes| ScriptLogic{Which Script?}
ScriptLogic -->|netswitchhome.bat| DHCP_Set[netsh: Set IP to DHCP]
ScriptLogic -->|netswitchlab.bat| Static_Set[netsh: Set IP to Static<br/>10.2.11.80]
DHCP_Set --> Confirm[✅ HOME Enabled]
Static_Set --> DNS_Set[netsh: Set DNS to 8.8.8.8]
DNS_Set --> Confirm
Confirm --> Feedback[Feedback Window<br/>Press Enter to Exit]
RunError --> Help[Read Troubleshooting Section]
- Windows: Windows 10/11 with Administrator rights
- Linux: A NetworkManager-based system with
nmcliinstalled andsudoaccess - Network: Standard Ethernet adapter
- Download or clone this repository.
- Use the Windows batch files on Windows:
netswitchhome.batnetswitchlab.bat
- Use the Linux shell scripts on Linux:
netswitchhome.shnetswitchlab.sh
- Place them in a preferred folder.
Best for: Home, Office, or dynamic environments.
- Right-click
netswitchhome.bat. - Select "Run as administrator".
- The script will configure the interface to request an IP from your local router.
- Success: You will see
HOME network enabled successfully.
Best for: Lab environments requiring fixed IP addresses.
- Right-click
netswitchlab.bat. - Select "Run as administrator".
- The script applies the static configuration:
- IP:
10.2.11.80 - Mask:
255.255.252.0 - Gateway:
10.2.8.1 - DNS:
8.8.8.8
- IP:
- Success: You will see
LAB network configured successfully.
💡 Tip: Always verify your settings after running by opening Command Prompt and typing
ipconfig.
Best for: Linux systems using NetworkManager.
Run the scripts with sudo:
sudo ./netswitchhome.sh
sudo ./netswitchlab.shThe Linux scripts try to detect the active Ethernet interface and its NetworkManager connection automatically.
If your setup needs a specific interface or connection name, you can override them:
sudo INTERFACE_NAME=enp3s0 ./netswitchhome.sh
sudo INTERFACE_NAME=enp3s0 CONNECTION_NAME="Wired connection 1" ./netswitchlab.shYou can also override the lab network values:
sudo IP_ADDRESS=10.2.11.80/22 GATEWAY=10.2.8.1 DNS_SERVER=8.8.8.8 ./netswitchlab.shBoth scripts look for a variable named %eth%. If your adapter is named Wi-Fi or Local Area Connection, modify this line in the script:
:: Default (Ethernet)
set eth=Ethernet
:: Example for Wi-Fi
set eth="Wi-Fi"To change the Lab IP address or Gateway, edit netswitchlab.bat:
:: Modify your static IP line
netsh interface ip set address name="%eth%" static 192.168.1.50 255.255.255.0 192.168.1.1
:: Modify DNS line
netsh interface ip set dns name="%eth%" static 1.1.1.1For Linux, you can either edit netswitchlab.sh or pass values at runtime:
sudo IP_ADDRESS=192.168.1.50/24 GATEWAY=192.168.1.1 DNS_SERVER=1.1.1.1 ./netswitchlab.sh| Issue | Possible Cause | Solution |
|---|---|---|
| Access Denied | Running without Admin rights | Right-click and select "Run as administrator". |
| Wrong Network | Interface name mismatch | Edit %eth= in the batch file to match your adapter name. |
| No Internet | Firewall/Antivirus block | Temporarily disable security software or add an exception for netsh. |
| Settings Not Saving | Network service reset | Restart the computer or the specific network adapter service. |
This tool is provided "as is" for educational and personal use.
- Network Modification Warning: Changing network configurations can temporarily disrupt connectivity. Always ensure you understand the IP subnet being applied to avoid network conflicts.
- Data Backup: If in doubt, perform a network backup (
ipconfig /all) before making changes.
Developed with 🧠 for efficient network management.