Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I'm wondering if its possble to alias an entire subnet in one hit rather than doing individual IP's with: ifconfig eth0:1 1.2.3.4 ifconfig eth0:2 1.2.3.5 . ifconfig eth0:50 1.2.3.54 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    Multiple interface aliases - entire subnet


    Hi,
    I'm wondering if its possble to alias an entire subnet in one hit rather than doing individual IP's with:

    ifconfig eth0:1 1.2.3.4
    ifconfig eth0:2 1.2.3.5
    .
    ifconfig eth0:50 1.2.3.54

    I'm wanting to alias an entire /21 subnet so doing it this way isnt practical and maybe not even possible (is there a limit on how many aliases you can have?).

    I thought maybe this is possible with ip route or similar.

    Any help would be appreciated,
    Rob.

  2. #2
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2
    #! /bin/bash

    for NUM in $(seq 1 255);
    do
    ip addr add 1.2.3.$NUM/21 broadcast + dev eth0
    done

    Nest for loops for modifying the preceding octets

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •