Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

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} dev eth0
    done
fi

# EOF

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.

share|improve this answer

Linode published a great article on how to do this

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

share|improve this answer
    
Note that this doesn't cover how to add a range. It just describes the "descriptive method", i.e. multiple iface eth0:1 stanzas. –  Alastair Irvine Mar 20 at 5:23

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

share|improve this answer

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
.
.
.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.