billgufran
Posts: 4
Joined: Sun Apr 15, 2018 6:16 am

/etc/network/interfaces in Raspbian Stretch

Sun Apr 29, 2018 1:50 pm

Hello, I would like to ask. Is there any way to use /etc/network/interfaces in stretch? I'm trying to setup static ip for several interfaces and setting up ad-hoc as well. It was kinda easy to do in old wheezy or jessie.

hippy
Posts: 6744
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: /etc/network/interfaces in Raspbian Stretch

Sun Apr 29, 2018 6:55 pm

billgufran wrote:
Sun Apr 29, 2018 1:50 pm
Is there any way to use /etc/network/interfaces in stretch?
Yes; just do it. People will say that's not the way to do it but if it works, achieves what you want, then job done.

It is what I have done to achieve multiple static IP addresses on my Pi on different subnets because suggestions for 'doing it properly' failed to achieve the desired results. I invested hours of time in trying to make it work 'the proper way'. A 30 second edit of /etc/network/interfaces did the job just fine.

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

Re: /etc/network/interfaces in Raspbian Stretch

Sun Apr 29, 2018 7:22 pm

If you're going to use /etc/network/interfaces then you need to add a

Code: Select all

denyinterfaces eth0
or

Code: Select all

denyinterfaces wlan0
or

Code: Select all

denyinterfaces enxb827ebbecafe
or

Code: Select all

denyinterfaces wlxdeadbeefcafe
line into /etc/dhcpcd.conf to avoid getting two DHCP addreses (or one static and one DHCP address) assigned to the interface.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6183
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: /etc/network/interfaces in Raspbian Stretch

Mon Apr 30, 2018 8:55 am

dhcpcd won't start if you have configured /etc/network/interfaces

The most common mistake people make in the interfaces file is forgetting the 'auto eth0' line.

The only downside is that the default desktop is not set up for it, which shouldn't be a problem for people who use ifupdown.

jbudd
Posts: 1081
Joined: Mon Dec 16, 2013 10:23 am

Re: /etc/network/interfaces in Raspbian Stretch

Mon Apr 30, 2018 9:28 am

You can (sort of) have static IP addresses for multiple networks with DHCP too.

Create a file /etc/dhcpcd.exit-hook containing something like this

Code: Select all

aliasip=

if $if_up; then
    # Wireless alias
    case "$ifssid" in
    EE-BrightBox-abcdef) aliasip="192.168.1.142/24";;
    MyOffice) aliasip="10.10.10.142/24";;
    esac

    # Ethernet alias
    case "$interface" in
    eth0) aliasip="192.168.1.148/24";;
    esac

    if [ -n "$aliasip" ]; then
       echo "Adding alias of $aliasip to $interface"
       ip a a "$aliasip" dev "$interface"
    fi
fi
This sets up a second, static alias IP for whichever network you are connected to.

It's best to choose a static IP that's not going to be allocated by DHCP on the router.

I have not tried this with Stretch but it worked with Jessie.

suiluj
Posts: 4
Joined: Sat May 05, 2018 5:07 pm

Re: /etc/network/interfaces in Raspbian Stretch

Sun May 06, 2018 7:55 pm

billgufran wrote:
Sun Apr 29, 2018 1:50 pm
Hello, I would like to ask. Is there any way to use /etc/network/interfaces in stretch? I'm trying to setup static ip for several interfaces and setting up ad-hoc as well. It was kinda easy to do in old wheezy or jessie.
hello @billgufran i am trying to do the same thing with several raspberry 3 B+ and raspberry pi zero w.

i tried the following command for switching wlan0 to ad-hoc

Code: Select all

sudo iw wlan0 set type ibss
But it responded:

Code: Select all

[email protected]:~ $ sudo iw wlan0 set type ibss
command failed: Device or resource busy (-16)
Did you have success or any idea?

suiluj
Posts: 4
Joined: Sat May 05, 2018 5:07 pm

Re: /etc/network/interfaces in Raspbian Stretch

Fri May 18, 2018 4:54 pm

Currently i am writing some tutorials on how to create a mqtt adhoc mesh cluster network with several raspberry pi 3 b+ and zero w.
My script uses the ip and iw commands for creating the adhoc network which work on the newest Raspbian Stretch version.
So everybody who is interested in using adhoc and batman on a raspberry pi with the newest raspbian (2018-04-18) just give it a try:

Link to my github tutorial on how to install and configure batman-adv on a raspberrypi:
https://github.com/suiluj/pi-adhoc-mqtt ... and-batctl

Hint:
If you do not want to use batman-adv (really cool software to create an adhoc mesh) just ignore the batman parts.

billgufran
Posts: 4
Joined: Sun Apr 15, 2018 6:16 am

Re: /etc/network/interfaces in Raspbian Stretch

Sat Jul 13, 2019 11:38 am

suiluj wrote:
Fri May 18, 2018 4:54 pm
Currently i am writing some tutorials on how to create a mqtt adhoc mesh cluster network with several raspberry pi 3 b+ and zero w.
My script uses the ip and iw commands for creating the adhoc network which work on the newest Raspbian Stretch version.
So everybody who is interested in using adhoc and batman on a raspberry pi with the newest raspbian (2018-04-18) just give it a try:

Link to my github tutorial on how to install and configure batman-adv on a raspberrypi:
https://github.com/suiluj/pi-adhoc-mqtt ... and-batctl

Hint:
If you do not want to use batman-adv (really cool software to create an adhoc mesh) just ignore the batman parts.

Hey thank you so much for the guide! It's really helpful. But I actually trying to make Batman meshnode with bridge (like the option 2 from your Batman Adv and Batctl guide) between wlan0 (adhoc interface) and wlan1 (usb wifi), where wlan1 act as wifi client and hotspot at the same time. So principally, the wifi client of wlan1 hotspot will get access to adhoc network. I'm not sure if it's possible or not, I guess I'll just do some trial and error based on your guides.

Return to “Troubleshooting”