1

I want add a range or IP address 192.168.1.128 to 192.168.1.254 to my debian host I know, there is an range file (such as ifcfg-eth0-range0) in RedHat/CentOS, they have IPADDR_START/IPADDR_END, but how to do in debian?

user73504
  • 21
  • 1
  • 2

4 Answers4

2

You could an ifup to use a script to add the addresses for you. Create the following script as /etc/network/if-up.d/eth0

#!/bin/bash

if [ "$IFACE" eq "eth0" ]; then
    for IP in {128..254}; do
        ip addr add 192.168.1.${IP}/24 dev eth0
    done
fi

# EOF

/24 should be replaced by the appropriate subnet mask.

A corresponding script in /etc/network/if-down.d/eth0 should be created using "ip addr" del in place of "ip addr add".

Be sure to run chmod +x on both scripts.

You can test the script using the command IFACE=eth0 /etc/network/if-up.d/eth0.

You could also create the file as /usr/local/sbin/eth0-aliases and run it from an up option in /etc/network/interfaces. Add up /usr/local/sbin/eth0-aliases to the eth0 stanza. If you use this mechanism you don't need the if condition in the script.

BillThor
  • 27,737
  • 3
  • 37
  • 69
1

You have to do it manually for each interface. Edit /etc/network/interfaces and add each one to that e.g.

auto lo
iface lo inet loopback

auto eth0
auto eth0:1
auto eth0:2
iface eth0 inet static
         address 192.168.10.1
         netmask 255.255.255.0
         gateway 192.168.10.100

iface eth0:1 inet static
         address 192.168.10.2
         netmask 255.255.255.0
         gateway 192.168.10.100

iface eth0:2 inet static
         address 192.168.10.3
         netmask 255.255.255.0
         gateway 192.168.10.100
.
.
.
user9517
  • 115,471
  • 20
  • 215
  • 297
0

Linode published a great article on how to do this

http://www.linode.com/wiki/index.php/Multiple_IPs

Frands Hansen
  • 4,657
  • 1
  • 17
  • 29
-1

You can probably only add every IP on its own to a virtual interface. Refer to this FAQ entry.

Adrian Heine
  • 328
  • 4
  • 22