How to Add Second IP on Raspberry Pi

  • Post author:
  • Post category:Linux

I originally had one WAN static IP address assigned to my Raspberry Pi (i.e. 99.100.100.82). I wanted to add a second (99.100.100.83).

The way I did that was to leave dhcpcd.conf alone, which included this definition of the first IP.

/etc/dhcpcd.conf:

interface eth0
static ip_address=99.100.100.82/29
static routers=99.100.100.81
static domain_name_servers=8.8.8.8

To add the second IP, I created a file in /etc/network/interfaces.d called eth0-subs and added the info for the second IP.

/etc/network/interfaces.d/eth0-subs:

auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
vlan-raw-device eth0
address 99.100.100.83
netmask 255.255.255.248
gateway 99.100.100.81

I rebooted the Raspberry Pi:

sudo reboot 

and when it came back up both IPs were functional.

See the following for more information:
https://raspberrypi.stackexchange.com/questions/89927/create-multiple-ip-adresses-on-pi

This was performed on Raspian 9 (stretch) in May, 2019.

Jason

Jason works as a project specialist at an IT MSP in Pennsylvania, USA. He's an IT/security professional with 20 years experience.