0
serkam

How to set static IP in eth0 and wlan0 in OPi Zero

Recommended Posts

Hi

 

I need to set static IP in eth0 and wlan0 in my OPi Zero using ARMBIAN Jessie.

 

Googling around, I read a lot of controversial options, like edit /etc/network/interfaces and use nmtui, but, I couldn't set BOTH eth0 and wlan0 to a static IP. If I do it for eth0, wlan0 doesn't work and vice-versa.

 

One guy said that after Debian Jessie version (https://nebulousthinking.wordpress.com/2016/02/25/setting-a-static-ip-for-raspbian-jessie-in-2016/), some things changed to set up static IP. Now, from Jessie, we need to edit  /etc/ dhcpcd.conf, but, where is it ( dhcpcd.conf )?

 

Can someone instruct me about how to set static IP, please?

 

Sergio

 

 

Share this post


Link to post
Share on other sites

Sorry, why do you think anything on the net for Raspbian would apply to Armbian? Raspbian is not Debian Jessie since they had to rebuild all packages for their ultra slow ARMv6 BCM2835 SoC used on the RPi first generation (that's also the reason why RPi 2, 2B and 3 do not perform as they could). It's just that Raspbian devs followed most upstream design principles (switching to systemd as 'init system' for example) since reinventing every wheel is not the best idea.

 

If you're asking about a recent Armbian version then you could either remove eth0 entirely from /etc/network/interfaces, reboot and then manage every interface with network-manager (nmtui or nmcli combined with sudo). Or fiddle around in static config files. Since I don't like stupid and anachronistic attempts I would recommend using the modern method (works flawlessly as long as you keep in mind that such a dynamic configuration attempt like network-manager requires some changes in other areas too: Eg. configuring DNS servers in /etc/resolv.conf will of course not work since DNS servers are part of the active NM profile you're using and resolv.conf will be overwritten every time a NM profile changes)

Share this post


Link to post
Share on other sites

First you need to know which network management you are using ?

 

If the /etc/network/interfaces is empty you probably have network manager and should do all with nmcli or nmtui.
If not you have wpa_supplicant for wireless

 

When using non networkmanager (like plain Ubuntu server images do) both lan and wireless ip-management is defined at /etc/network/interfaces.
wpa_supplicant is only required for the wireless selection (not the actual ip-address) and triggered from /etc/network/interfaces

 

But when you have the network manager the ip-address don't come straight from the /etc/network/interface and relays to the problems marked at your post and you need to make certain scripts to auto load the settings

 

Hi

 

I need to set static IP in eth0 and wlan0 in my OPi Zero using ARMBIAN Jessie.

 

Googling around, I read a lot of controversial options, like edit /etc/network/interfaces and use nmtui, but, I couldn't set BOTH eth0 and wlan0 to a static IP. If I do it for eth0, wlan0 doesn't work and vice-versa.

 

One guy said that after Debian Jessie version (https://nebulousthinking.wordpress.com/2016/02/25/setting-a-static-ip-for-raspbian-jessie-in-2016/), some things changed to set up static IP. Now, from Jessie, we need to edit  /etc/ dhcpcd.conf, but, where is it ( dhcpcd.conf )?

 

Can someone instruct me about how to set static IP, please?

 

Sergio

Share this post


Link to post
Share on other sites

Hi Tkaiser

 

My apologies about my misunderstanding that knowledge about Raspbian Jessie can not apply for Armbian Jessie. That is very confusing for me, as, until now, I wondered that linux was a unique thing around the world. For sure, Torvald is not happy regarding for such much "flavors" around *bian(s).

 

Anyway, I just started with a fresh uSD card with the last Armbian Jessie ( from https://dl.armbian.com/orangepizero/) and configured the wifi.

 

Both interfaces, eth0 and wlan0 are operating normally, with dynamic IP. I can ping both.

 

But, if I try to fix the IP ( manual ) on eth0, using nmtui, the OPi Zero boots normally, logging as root, the eth0 shows the IP that I configured, but, it is not responding for ping. Wlan0 continues OK ( respond to ping ).

 

Is it necessary more setup anywhere along nmtui?

 

Any help will be welcome.

 

Thanks.

 

Sergio

Share this post


Link to post
Share on other sites

p.s) Raspbian is based on Debian Jessie. They just don't follow the normal debian development and manually merge the security patches (when ever feel like it, so not often).

Therefore basic Debian guides will work unless we are talking something on lower level arm support etch.
 

 

Hi Tkaiser

 

My apologies about my misunderstanding that knowledge about Raspbian Jessie can not apply for Armbian Jessie. That is very confusing for me, as, until now, I wondered that linux was a unique thing around the world. For sure, Torvald is not happy regarding for such much "flavors" around *bian(s).

 

Anyway, I just started with a fresh uSD card with the last Armbian Jessie ( from https://dl.armbian.com/orangepizero/) and configured the wifi.

 

Both interfaces, eth0 and wlan0 are operating normally, with dynamic IP. I can ping both.

 

But, if I try to fix the IP ( manual ) on eth0, using nmtui, the OPi Zero boots normally, logging as root, the eth0 shows the IP that I configured, but, it is not responding for ping. Wlan0 continues OK ( respond to ping ).

 

Is it necessary more setup anywhere along nmtui?

 

Any help will be welcome.

 

Thanks.

 

Sergio

Share this post


Link to post
Share on other sites

But, if I try to fix the IP ( manual ) on eth0, using nmtui, the OPi Zero boots normally, logging as root, the eth0 shows the IP that I configured, but, it is not responding for ping. Wlan0 continues OK ( respond to ping ).

 

Different problem. You're using the smelly legacy kernel and try to use both NICs connected to the same network which is not working (MAC address / routing issue). Too tired to search for the thread now where everything is explained but rule of thumb: Don't do this, if you want to use both NICs they have to connect to different networks.

 

p.s) Raspbian is based on Debian Jessie.

 

So I can exchange the repo in sources.list to Jessie's and it works now mixing armhf Jessie packages with ARMv6 Raspbian packages? Of course it won't. RPi people are great telling fairy tales (the mythical RPi foundation so busy in charity that they don't need to pay taxes) and try hard to not confuse the average fanboi by always telling simple stories. That's why they call their releases 'Wheezy' or 'Jessie' since most of their stuff complies with original Debian releases.

 

Anyway: It was about network settings and here things are different on Raspbian (see Sergio's example config, another example is Raspbian being more user-friendly and enabling ZeroConf by default starting with one of their latest releases they call 'Jessie' compared to vanilla Jessie where you don't get an 169.254.0.0/16 address when there's no DHCP server present in the broadcast domain connected to), on vanilla Jessie (even on armhf) and on Armbian (since Armbian tries to 'optimize' some settings). So the important rule is just: Forget about tutorials for Raspbian when it's about Armbian. Better look through documentation (still a lot missing but we lack contributors also in this area) or ask in the Forum first :)

Share this post


Link to post
Share on other sites

Hi Tkaiser

 

If I understood correctly,  to have static IP working in eth0, I need to disable wlan0 or set it up as AP, for example?

 

Sergio

Share this post


Link to post
Share on other sites

If I understood correctly,  to have static IP working in eth0, I need to disable wlan0 or set it up as AP, for example?

 

I was referring to a problem occuring when you connect two or more network interfaces on any H3/H2+ device with legacy kernel to the same network: https://forum.armbian.com/index.php/topic/2907-opi-zero-incoming-ssh-cant-connect/page-2 (read at the end of this thread).

 

Just try to avoid that for your tests since it requires some networking skills to workaround the problem. So if you choose 192.168.1.0/24 for Ethernet and 192.168.2.0/24 for Wi-Fi this will work but not both interfaces in the same 'network range'.

Share this post


Link to post
Share on other sites

Hi tkaiser and martinayotte.

 

The real problem I was facing was due incorrect static IP address. I was trying to use 192.168.1.100 without /24. Doing this, nmtui automatically places /32 and the IP MASK is set to 255.255.255.255 and broadcast IP to 192.168.1.100 ( the same IP of my device).

 

Setting IP to 192.168.1.100/24, all the rest is adjusted correctly ( 255.255.255.0 and 192.168.1.255 ).

 

I did the same for wlan0 ( 192.168.1.99/24 ) and now both (eth0, wlan0) are working fine.

 

I did a test using Visual Studio with linux plugin that use SSH to communicate with OPi Zero at eth0 and all worked fine. 

 

As I intend to use wlan0 as AP to control a MQTT's network of IoTs devices, I wonder that the routing issue will be solved too.

 

Thank you all people. Your support are great!

 

Sergio

Share this post


Link to post
Share on other sites

As I intend to use wlan0 as AP to control a MQTT's network of IoTs devices, I wonder that the routing issue will be solved too.

 

Great that you were able to resolve the issue and especially that you shared solution/knowledge!

 

Please don't expect too much from legacy kernel here. This is an ancient 3.4 kernel from Allwinner that is known to have several networking issues. Also please be aware that problems on layer 3 (routing) might not even exist when the problem is solved at the appropriate layer (that would be 2 --> bridging). I did some tests with 3.4.113 and bridging that went well but in case you're running in problems it would be worth a try to test out the nightly builds with dev kernel to know whether the problem is solveable with mainline kernel (then it's just having some patience since OS images based on mainline kernel receive no end user support ATM)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
0