• HWIKI

    Build. Break. Explain.

    Navigating Two Subnets with a Single Net

    Recently, I helped a user who was stuck on a configuration task. He had to set up a piece of equipment with a default IP address of 192.168.1.1/24, while his own network was on a completely different range.

    To access the management interface, he would change his machine's IP, apply his configuration, and then switch back to his original IP to regain standard network access. This quickly becomes tedious when you have to go back and forth.

    I showed him a simple technique to avoid this hassle: assigning multiple IP addresses to a single network interface. I thought this was a widely known trick, but it turns out it is worth writing an article about.

    The Concept

    The idea is to configure the operating system so that the network card can communicate on a second subnet in parallel. There is no need to switch your network configuration back and forth. This is a native feature on both Linux and Windows.

    The Linux Method (Temporary)

    For troubleshooting, we usually add an IP on the fly directly in the terminal. The advantage of this method is its temporary nature. Upon the next restart of the network service or the machine, the IP disappears, which keeps your system configuration clean.

    We use the ip command for this:

    bash
    # First, identify the name of your target network interface (e.g., eth0, enp3s0)
    ip addr show
    
    # Assign a secondary IP address to the same interface
    sudo ip addr add 192.168.1.50/24 dev enp3s0
    
    

    Once the command is executed, you can directly access the equipment at 192.168.1.1 while maintaining the connection to your main network.

    When you are done, you can remove the temporary IP using del:

    bash
    # Remove the temporary IP address to keep a clean state
    sudo ip addr del 192.168.1.50/24 dev enp3s0
    
    

    On Windows

    The approach is identical on Windows, but it is handled through the graphical interface.

    You need to go to the network adapter properties via the Control Panel. In the TCP/IPv4 protocol properties, click on the "Advanced..." button. In the first tab, the "IP Addresses" section allows you to add a new address and its subnet mask using the "Add" button.

    It is a quick adjustment that saves a significant amount of time when deploying or configuring new equipment.


    Made by h0ag