How to Add Multiple IP Addresses to the Network Card in Linux

104 8

    RedHat Based Linux Distributions

    • 1). Log in to the Linux computer using the root account name and password. If the computer does not allow root log-in, then log in using the credentials of an administrator account.

    • 2). Open a command line terminal. Type "ifconfig" at the command prompt, and press the "Enter" key. Note the name (such as "eth0") of the network interface you wish to assign multiple IP addresses.

    • 3). Open a text editor such as Gedit or Kate. Click the "File" menu, and click "Open." Navigate to the "/etc/sysconfig/network-scripts/ifcfg-eth0" file, except replace the "eth0" with the name of the network interface that you wish to assign multiple IP addresses. Press "Enter" to open the file.

    • 4). If the "IPADDR" and "NETMASK" parameters in the content displayed are configured with an IP address and subnet mask you wish to set up on the network card, then proceed to the next step. Otherwise, enter an IP address immediately after the "IPADDR=" parameter displayed. Enter the subnet mask for the IP address immediately after the "NETMASK=" parameter displayed. Enter the broadcast address for the network immediately after the "BROADCAST=" parameter displayed. Enter the network address immediately after the "NETWORK=" parameter displayed. Enter "static" immediately after the "BOOTPROTO=" parameter displayed.

    • 5). Highlight the number immediately following the "HWADDR=" parameter. Click the "Edit" menu item at the top of the window, and then click "Copy" in the menu that appears.

    • 6). Click the "File" menu at the top of the text editor window, and click "Save." Click the "File" menu at the top of the text editor and click "New." A new, blank text document will appear. Type the following into the new text document:

      # File: ifcfg-eth0:1

      DEVICE=eth0:1

      ONBOOT=yes

      BOOTPROTO=static

      IPADDR=

      NETMASK=

      BROADCAST=

      NETWORK=

      HWADDR=

    • 7). Place the mouse pointer immediately after the "HWADDR=" parameter, and left-click once to place the cursor after the "HWADDR=" parameter. Click the "Edit" menu item at the top of the window and click "Paste" in the menu that appears. The hardware address copied earlier will appear after the "HWADDR=" parameter. Enter an IP address immediately following the "IPADDR=" parameter. Enter the subnet mask for the IP address immediately following the "NETMASK=" parameter. Enter the broadcast address for the network immediately following the "BROADCAST=" parameter. Enter the network address immediately following the "NETWORK=" parameter. Click "File," and click "Save As." Then type "ifcfg-eth0:1" as the name of the file, and click "Save" or "OK."

    • 8). Repeat the previous two steps for each IP address you wish to configure on the network adapter and increment the last number in the "ifcfg-eth0:1" parameter and in the file name in each configuration file created.

    • 9). Reboot the computer. Log in using the username and password of an administrator or root account. Open a command line, and type "ifconfig" at the command prompt. Press the "Enter" key, and confirm that all IP addresses configured are displayed.

    Debian/Ubuntu Based Linux Distributions

    • 1). Log in to the Linux computer using the root account name and password. If the computer does not allow root log-in, then log in using the credentials of a user account. Open a command line terminal. Type "sudo ifconfig" at the command prompt, and press "Enter." Type the root password if prompted, and press "Enter." Note the name (such as "eth0") of the network interface you wish to assign multiple IP addresses.

    • 2). Open a text editor such as Gedit or Kate. Click the "File" menu, and click "Open." Then navigate to the "/etc/network/interfaces" file, click on the file, and press "Enter" to open the file. Locate the name of the network interface in the content of the open file. If the "address" and "netmask" parameters are configured with an IP address and subnet mask you wish to set up on the network card, then proceed to the next step. Otherwise, enter an IP address one space after the "address" parameter displayed. Enter the subnet mask for the IP address one space after the "netmask" parameter. Enter the broadcast address for the network one space after the "broadcast" parameter. Type the network address one space following the "network" parameter displayed. Enter "static" one space following the "inet" parameter. Enter the gateway IP address one space following the "gateway" parameter. Type the DNS IP address for the network one space following the "dns-nameservers" parameter.

    • 3). Click on empty space in the file and type the following into the file:

      auto eth0:0

      iface eth0:0 inet static

      address

      netmask

      Replace the "eth0:0" with the name of the network adapter you wish to assign multiple IP addresses immediately followed by the ":0" suffix. Type an IP address one space after the "address" parameter. Enter the subnet mask for the IP address one space following the "netmask" parameter.

    • 4). Repeat the previous step for each IP address you want to set up on the network adapter and increment the last number in the network adapter name parameter in each configuration stanza created. Ensure that each stanza added to the file is separated from the others by at least one line.

    • 5). Click the "File" menu item near the top of the text editor window, and click "Save" in the menu that appears. Reboot the computer. Log in using the user name and password of the same account used earlier. Open a command line, and type "sudo ifconfig" at the command prompt and tap the "Enter" key. Type the root password if requested and press the "Enter" key. Confirm that all IP addresses configured are displayed in the command line output.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.