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

I just installed Debian Wheezy on my homeserver. I want to assign 2 ip's to it on the same network interface, 1 static ip (eth0) and 1 dynamic ip (eth0:1). I know it doesn't make much sense but I need it to test something.

I edited my /etc/network/interfaces to be like this:

auto lo eth0 eth0:1
iface lo inet loopback

iface eth0 inet static
     address 192.168.178.240
     network 192.168.178.0
     netmask 255.255.255.0
     broadcast 192.168.178.255
     gateway 192.168.178.1


iface eth0:1 inet dhcp

when I bring up eth0:1 (ifup eth0:1) I get the following error (eth0 works fine)

Bind socket to interface: No such device

Failed to bring up eth0:1.

is it even possible to have a dynamic and static ip on the same network adapter?

share|improve this question
add comment

closed as off topic by SvW, EEAA, Scott Pack, petrus, Greg Askew Dec 2 '12 at 20:20

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 0 down vote accepted

You might try:

iface eth0 inet dhcp
post-up /sbin/ip addr add 192.168.178.240/24 dev eth0
share|improve this answer
    
Looks like that worked, thx! –  David Dec 2 '12 at 18:53
    
@David what's the output of ifconfig now that it works? Put it somewhere to something like pastebin.com. –  ott-- Dec 2 '12 at 19:10
    
@ott pastebin.com/raw.php?i=Ax4rvgMa It doesn't show the static ip but I can ssh to the server via both ip's –  David Dec 2 '12 at 20:13
    
@David that only shows eth0. A simple ifconfig without parameters would show eth0:0 and others too. –  ott-- Dec 2 '12 at 20:18
    
Using /sbin/ip adds secondary IPs directly to an interface, which ifconfig doesn't know how to deal with for IPv4 addresses. (The alias-interface style -- eth0:0 -- and the ifconfig utility are deprecated.) '/sbin/ip addr show' will list all the IPs on the interface. –  techieb0y Dec 2 '12 at 21:49
show 2 more comments

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