suibaf
Posts: 10
Joined: Sun Feb 07, 2016 2:15 pm
Location: Galatina

two address ip in raspbian stretch

Sat Oct 20, 2018 9:19 am

Hi,
with Jessie I have no problem to set for eth0 2 ip address. In Stretch it no work.

My goal is to have in streatch 2 statip ip address or, better,
one assigned from dhcp and one static.
Thanks in advance.

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: two address ip in raspbian stretch

Sat Oct 20, 2018 11:25 am

Add this

Code: Select all

    auto eth0
    iface eth0 inet static
        address 192.168.3.14
        netmask 24
        gateway 192.168.3.254
to /etc/network/interfaces [change numbers to suit your network].

Leave /etc/dhcpcd.conf alone.

That's just about guaranteed to get a static and a DHCP address assigned to your eth0 interface.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

suibaf
Posts: 10
Joined: Sun Feb 07, 2016 2:15 pm
Location: Galatina

Re: two address ip in raspbian stretch

Sat Oct 20, 2018 1:17 pm

Leave /etc/dhcpcd.conf alone.
What do you mean?

dhcp assign to raspberry 192.168.1.197/24 and it's ok.

I need anoter ip: 192.168.9.150

BR

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: two address ip in raspbian stretch

Sat Oct 20, 2018 3:58 pm

I mean don't change /etc/dhcpcd.conf from the version supplied when you installed Raspbian Stretch first time.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

suibaf
Posts: 10
Joined: Sun Feb 07, 2016 2:15 pm
Location: Galatina

Re: two address ip in raspbian stretch

Sun Oct 21, 2018 7:50 am

Hi DougieLawson,

it does not work maybe I need two different class IP address.

DHCP IP 192.168.1.10
Static IP: 192.168.0.150.

If I add your code in interfaces:

Code: Select all

 auto eth0
    iface eth0 inet static
        address 192.168.0.150
        netmask 24
        gateway 192.168.0.1
DHCP fail to assign the ip address.

Is there a solution?
BR

User avatar
rpdom
Posts: 12879
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: two address ip in raspbian stretch

Sun Oct 21, 2018 8:34 am

One possibility is to assign an alias interface in somewhere like /etc/rc.local

Add the line

Code: Select all

/sbin/ifconfig eth0:0 192.168.0.150/24
before the "exit 0" line and it should create a virtual interface called eth0:0 with that IP address which will use eth0 as the physical interface. It seems dhcpcd hasn't got the ability to handle interfaces like that.

suibaf
Posts: 10
Joined: Sun Feb 07, 2016 2:15 pm
Location: Galatina

Re: two address ip in raspbian stretch

Sun Oct 21, 2018 2:20 pm

Hi rpdom,

it work fine! Thank you! :)

Why this code must be write in /etc/rc.local?

BR

Return to “General discussion”