Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Configure IP Range Ubuntu Server
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Configure IP Range Ubuntu Server

agoldenbergagoldenberg Member, Host Rep

Is there a way to configure an IP range of aliases similar to Centos ifcfg-eth0-range0 type model?

Is there any way to accomplish this without having to manually input each ip into interfaces?

Comments

  • As far as I know you have to manually input each IP in the interfaces file however this approach may be slightly faster:

    auto eth0
    allow-hotplug eth0
    iface eth0 inet static
        address 192.168.1.1
        netmask 255.255.255.0
        gateway 192.168.1.254
        up   ip addr add 192.168.1.2/24 dev eth0 label eth0:0
        down ip addr del 192.168.1.2/24 dev eth0 label eth0:0
        up   ip addr add 192.168.1.3/24 dev eth0 label eth0:1
        down ip addr del 192.168.1.3/24 dev eth0 label eth0:1
    
  • JanevskiJanevski Member
    edited December 2013

    @agoldenberg Or if You need to initiate the interfaces only for the current session via ifconfig, a bit bogus example:

    ifconfig eth0 10.0.0.1/8 up
    ifconfig eth0:0 172.16.0.1/12 up
    ifconfig eth0:1 192.168.0.1/16 up
    

    Edit: Whoops sorry didn't read the whole thing, about the manual part, so my post is pretty much pointless, okay anyhow... as @fizzyjoe908 said.

    PS: You could put the ifconfig in /etc/rc.local, and achieve the same thing.

  • agoldenbergagoldenberg Member, Host Rep

    Yeah I guess I'm just going to configure them 1 by 1. It's too bad ubuntu doesn't have a way of configuring a range simply.

  • @agoldenberg said:
    Yeah I guess I'm just going to configure them 1 by 1. It's too bad ubuntu doesn't have a way of configuring a range simply.

    I think that you should write script for this.

  • RalliasRallias Member
    edited December 2013
    for i i n {2..255};
    do
         echo "auto eth0:$i" >> /etc/network/interfaces
         echo "iface eth0:$i inet static" >> /etc/network/interfaces
         echo "    address 10.0.0.$i" >> /etc/network/interfaces
         echo "    netmask 255.255.255.0" >> /etc/network/interfaces
    done
    service networking restart
    

    It's not "manual", but it is just as bad.

  • gbshousegbshouse Member, Host Rep

    Ip addr add dev eth0 1.2.3.0/24

  • gbshouse said: Ip addr add dev eth0 1.2.3.0/24

    You realize with the ip command, /24 refers to the appropriate netmask, not the range of address's to add, right?

  • gbshousegbshouse Member, Host Rep

    Works for us, note the .0 part

Sign In or Register to comment.