Static IP on eth0

Hi! I put latest jessie debian snapshot from here http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

Well, i want to have an ip to the beaglebone. I put this in /etc/network/interfaces:

auto eth0
iface eth0 inet static
#your static IP
address 192.168.1.26
#your gateway IP
gateway 192.168.1.1

But when restart the ip are 192.168.1.130 (provided by DHCP server). If after reboot i execute /etc/init.d/networking restart then ip change to 192.168.1.26 but if i ping 192.168.1.130 the beagle responds correctly.

So Any ideas? Thanks!

Try this:

auto eth0
iface eth0 inet static
address 192.168.1.26
netmask 255.255.255.0
gateway 192.168.1.1

That worked for me.

That is like i have but the problem is that when reboot the beaglebone i lose the configuration until i reboot networking manually.

El divendres, 13 febrer de 2015 13:42:38 UTC+1, COG va escriure:

Did you include the netmask 255.255.255.0 line? You should probably send the ‘interfaces’ (Assuming your using Debian: /etc/network/interfaces) file as an attachment so follks can check it out.

Yes, ok this night i will attach it :wink: thanks!

El divendres, 13 febrer de 2015 18:27:03 UTC+1, COG va escriure:

Ok, here is my /etc/network/interfaces file :

This file describes the network interfaces available on your system

and how to activate them. For more information, see interfaces(5).

The loopback network interface

auto lo
iface lo inet loopback

The primary network interface

auto eth0
iface eth0 inet static
address 192.168.1.26
netmask 255.255.255.0
gateway 192.168.1.1

Example to keep MAC address between reboots

#hwaddress ether DE:AD:BE:EF:CA:FE

The secondary network interface

#auto eth1
#iface eth1 inet dhcp

WiFi Example

#auto wlan0
#iface wlan0 inet dhcp

wpa-ssid “essid”

wpa-psk “password”

Ethernet/RNDIS gadget (g_ether)

… or on host side, usbnet and random hwaddr

Note on some boards, usb0 is automaticly setup with an init script

iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1

It wirks but i must restart networking service on startup. (/etc/init.d/networking restart)
If i dont restart it eth0 doesnt have any configuration with no ip no gateway and no netmask assigned.
What can i do ?
Thanks!

El divendres, 13 febrer de 2015 18:37:07 UTC+1, Enric Climent va escriure:

Does the router/dhcp server config have to be considered? On my routers I usually make < .100 fixed IP and start dhcp service above that. If your router is not configured that way I wonder what would happen? I’ll try this myself since now I am curious. (So far on BBB I’ve just been using DHCP.)

Enric,

I think your problem may be related to ConnMan. ConnMan is a network manager that is installed on the Jessie test images. It manages your network connections, including eth. Any settings you have in /etc/network/interfaces is overriden by ConnMan, and thus this is why you see a DHCP assigned address rather than the static address configured in /etc/network/interfaces when you reboot.

You can disable ConnMan (not recommended), tell ConnMan to not manage eth0 on your behalf and manage things yourself (again, not recommended), or use ConnMan to setup a static IP address. Using ConnMan to setup a static IP address will be “persistent”, that is it will survive reboots. This is pretty simple:

First, determine the “service” name of your ethernet:

connmanctl services

Using the appropriate ethernet service, tell connman to setup a static IP address for that service:

sudo connmanctl config --ipv4 manual <ip_addr> --nameservers <dns_server>

You will need to pick an IP address compatible with your network and router.

For example:

$ connmanctl services
*AO Wired ethernet_d05fb8ed4f78_cable
$ sudo connmanctl config ethernet_d05fb8ed4f78_cable --ipv4 manual 10.0.1.100 255.255.255.0 10.0.1.1 --nameservers 8.8.8.8

You should then see the new address using the “ip” command:

$ ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d0:5f:b8:ed:4f:78 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.100/24 brd 10.0.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::d25f:b8ff:feed:4f78/64 scope link
valid_lft forever preferred_lft forever

You should now also be able to “ping” an address such as “google.com”.

You can revert back to a DHCP configuration simply as follows:

$ sudo connmanctl config ethernet_d05fb8ed4f78_cable --ipv4 dhcp

It would be best if you have a FTDI serial cable so you can see what is going on at the console in case something goes wrong. Actually, it would be best to issues these commands from the console rather than ssh’ing.

Hope this helps

ba

El dimarts, 17 febrer de 2015 4:44:33 UTC+1, Brian Anderson va escriure:

Enric,

I think your problem may be related to ConnMan. ConnMan is a network manager that is installed on the Jessie test images. It manages your network connections, including eth. Any settings you have in /etc/network/interfaces is overriden by ConnMan, and thus this is why you see a DHCP assigned address rather than the static address configured in /etc/network/interfaces when you reboot.

You can disable ConnMan (not recommended), tell ConnMan to not manage eth0 on your behalf and manage things yourself (again, not recommended), or use ConnMan to setup a static IP address. Using ConnMan to setup a static IP address will be “persistent”, that is it will survive reboots. This is pretty simple:

First, determine the “service” name of your ethernet:

connmanctl services

Using the appropriate ethernet service, tell connman to setup a static IP address for that service:

sudo connmanctl config --ipv4 manual <ip_addr> --nameservers <dns_server>

You will need to pick an IP address compatible with your network and router.

For example:

$ connmanctl services
*AO Wired ethernet_d05fb8ed4f78_cable
$ sudo connmanctl config ethernet_d05fb8ed4f78_cable --ipv4 manual 10.0.1.100 255.255.255.0 10.0.1.1 --nameservers 8.8.8.8

You should then see the new address using the “ip” command:

$ ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d0:5f:b8:ed:4f:78 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.100/24 brd 10.0.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::d25f:b8ff:feed:4f78/64 scope link
valid_lft forever preferred_lft forever

You should now also be able to “ping” an address such as “google.com”.

You can revert back to a DHCP configuration simply as follows:

$ sudo connmanctl config ethernet_d05fb8ed4f78_cable --ipv4 dhcp

It would be best if you have a FTDI serial cable so you can see what is going on at the console in case something goes wrong. Actually, it would be best to issues these commands from the console rather than ssh’ing.

Hope this helps

ba

Ok thanks i try it. For now i get static ip writing simple script and save it at /etc/init.d :
#!bash
/etc/init.d/networking restart

after:

update-rc.d fixnet defaults

And now i get static ip when reboot bbb.
So i try understant how connman works and will edit configuration for static ip at eth0.
Thanks a lot bro :wink:

This worked perfectly.
Thank you.

Thanks a lot Brian , I spent the whole sunday trying to find why static ip configurations was being “discarded” after reboot and found your answer.
I followed the instructions about ConnMan configuration for static ip and now BBB it’s functioning with static ip after reboot.
Regards ,
Jeronimo

Thanks Brian!!

This worked for me.
Was tearing my hair out going from Wheezy to Jessie

Thanks Brian,
Your post helped me. :slight_smile:

Hi Eric,
I followed your comment exactly and update /etc/network/interfaces file:

Use connman http://derekmolloy.ie/set-ip-address-to-be-static-on-the-beaglebone-black/

Hi

Check NetworkManager is not running.

Alvaro.

Dear Developers,

I am trying to do permanent configuration for default gateway in my debian(beaglebone black) machine by settings my network IP for interface usb0 and usb1 as static and doing following configuration in file “/etc/network/interfaces”

iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.252
gateway 192.168.7.1
dns-nameservers 8.8.8.8 8.8.8.4

iface usb1 inet static
address 192.168.6.2
netmask 255.255.255.252
gateway 192.168.6.1
dns-nameservers 8.8.8.8 8.8.8.4

But after I restart my machine I notice that 192.168.7.1 and 192.168.6.1 are not set as default gateway.

And I have to do it again by giving following commands:

route add default gw 192.168.7.1 usb0
route add default gw 192.168.6.1 usb1

So please inform me how can I configure default gateway in debian machine so that it stay configured even after restart.

Additionally I tried to configure it using command` “connmanctl”. But when I give command ```

*#connmanctl services*

*I do not get anything on my terminal window.*

*Please Note: I want to configure gateway for my ethernet over USB interface.*

``

Kindly inform me if you need any information from me.

Thanks and regards

saurabh Jain

Hi Saurahb,

The reason #connmanctl services is not returning anything, is because it’s probably not installed
I’m guessing you’re using an older Debian image
Jessie and above have connman (connection manager) and use it by default

Can you post what is returned from this command # uname -a

This is the image I’m using ATM (Debian Stretch)

uname -a

Linux beaglebone 4.4.110-ti-r144 #1 SMP Wed Jan 24 03:00:14 UTC 2018 armv7l GNU/Linux

It uses connman, usb0 and usb1 is blacklisted here root@beaglebone:/# nano /etc/connman/main.conf

[General]
PreferredTechnologies=ethernet,wifi
SingleConnectedTechnology=false
AllowHostnameUpdates=false
PersistentTetheringMode=true
*NetworkInterfaceBlacklist=SoftAp0,*usb0,usb1

Which means that connman ignores usb0 and usb1

You can change usb0 with # nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

## Now done via connmanctl
#auto eth0
#iface eth0 inet static
# address 192.168.1.152
# netmask 255.255.255.0
# gateway 192.168.1.1

# usb0
iface usb0 inet static
address 192.168.7.5
netmask 255.255.255.0
gateway 192.168.7.1

Changes will take effect after rebooting

However you can’t do this for usb1, you have to change it here # nano /opt/scripts/boot/autoconfigure_usb1.sh

#!/bin/bash

Hello Rudy

Thank you very much for your fast response

In my BBB

uname -a returns

Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l GNU/Linux

Yes, you are right in my BBB also usb0 and usb1 is blacklisted in file /etc/connman/main.conf. I will do the changes and will update you .

Thanks and regards

Saurabh