Trying to set two static ip in dhcpcd.conf, but second ip is not active.


interface eth0
    static ip_address=
    static routers=
    static domain_name_server=

interface eth0:1
    static ip_address=
    static routers=
    static domain_name_server=

ifconfig output:

inet addr:  Bcast:  Mask:

Does anyone faced similar situation.

4 Answers 4


Although it is said that /etc/network/interfaces is deprecated (read it everywhere online) so far the only way I have been able to make it work is in fact through /etc/network/interfaces.

The following should work for you, just put it in /etc/network/interfaces (you can leave out the gateway)

auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static

if you just want it to be temporary (not lasting after reboot) you could also use

sudo ifconfig eth0:1 
  • 5
    Instead of modifying /etc/network/interfaces, I leave the file /etc/network/interfaces untouched to keep dhcpcd working as intended, while adding a file such as /etc/network/interfaces.d/eth0-mydb to have the additional IP address configured.
    – VCD
    Jun 27, 2018 at 14:09
  • "The 'modern' way described in official Debian documentation in fact states that this new method is dangerous." -> You've badly misinterpreted that; I am going to edit it out (the link was: wiki.debian.org/…). What it says is dangerous has nothing to do with dhcpcd (which is what the question is actually about); the two methods described there ("legacy" and "iproute2") are both /etc/network/interfaces based. Beyond that your answer is reasonable enough.
    – goldilocks
    Jul 6, 2023 at 16:56

I suggest you use ip address show instead of ifconfig to see your ips, anyway with new debian/raspbian Jessie's versions, you may solve using multiple static configuration in this way:

interface eth0

static ip_address=
static routers=
static domain_name_servers=

static ip_address=
static routers=
static domain_name_servers=

source and more: Static IP address templates for dhcpcd.conf

  • 1
    I could not get this approach to work, while adding a clause to /etc/network/interfaces.d/eth0-xxx (as per @F. Pareto and answer) worked fine.
    – askvictor
    Jan 16, 2019 at 0:22
  • ok but you have to change that manually if you change network.. On the other hand, in my way, you need to know the addresses of the servers becouse If none of the arpings find an active machine then you will get a DHCP allocation
    – lunix15
    Jan 17, 2019 at 16:43
  • 4
    arping is for selecting one out of several possible static configurations, not for setting multiple IP addresses on one interface
    – Adrian W
    Feb 16, 2019 at 16:08

I got my raspberry pi(jessie) to run two IPs on the same interface and on the same vlan by appending "denyinterfaces eth0" to dhcpcd.conf, and running an @reboot crontab job using "ip" commands.

$ sudo nano /etc/dhcpcd.conf  
denyinterfaces eth0

$ sudo nano /etc/ipstartup
ip address flush dev eth0
ip address add dev eth0
ip address add dev eth0
ip link set eth0 up
ip route add default via
printf "nameserver\nnameserver" > /etc/resolv.conf

$ sudo chmod 740 /etc/ipstartup

$ sudo crontab -e
@reboot /etc/ipstartup
  • 1
    Although pleasingly simple,the trouble with this approach is that it doesn't do anything to make the address assingments happen before daemons (which want to bind these addresses!) are started. Myself I ended up writing my own initscript, so that it can be properly sequenced.
    – q.undertow
    Oct 16, 2020 at 0:14

yes, and a long time ago. Try /etc/network/interfaces : it's a proper place to make a config. DHCP client can assign only one IP, as DHCP protocol itself. Even more : DHCP is for getting a config from server. If you have a local per-host config, then use a proper place for it in your system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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