How to assign a secondary IP?

091

To assign a secondary IP address to a network interface, the method can vary depending on the operating system. Here are examples for both Linux and Windows:

On Linux

  1. Using the ip command:

    sudo ip addr add <secondary_ip_address>/<subnet_mask> dev <interface_name>

    Example:

    sudo ip addr add 192.168.1.10/24 dev eth0
  2. Using the ifconfig command (deprecated in some distributions):

    sudo ifconfig <interface_name> <secondary_ip_address> netmask <subnet_mask> up

    Example:

    sudo ifconfig eth0:0 192.168.1.10 netmask 255.255.255.0 up
  3. Persistent Configuration:
    To make the change persistent across reboots, you can edit the network configuration files, typically found in /etc/network/interfaces or /etc/sysconfig/network-scripts/ifcfg-<interface_name> depending on your distribution.

On Windows

  1. Using Command Prompt:
    Open Command Prompt as Administrator and run:

    netsh interface ip add address "<interface_name>" <secondary_ip_address> <subnet_mask>

    Example:

    netsh interface ip add address "Ethernet" 192.168.1.10 255.255.255.0
  2. Using GUI:

    • Go to Control Panel > Network and Sharing Center > Change adapter settings.
    • Right-click on the network interface and select Properties.
    • Select "Internet Protocol Version 4 (TCP/IPv4)" and click Properties.
    • Click on "Advanced" and then under the "IP Addresses" section, click "Add" to enter the secondary IP address.

Note

Make sure to replace <secondary_ip_address>, <subnet_mask>, and <interface_name> with the appropriate values for your network configuration.

0 Comments

no data
Be the first to share your comment!