Disappearing static IP address

Hi All,

I have a project with my Beaglebone Black which needs a static and dynamic IP. I set up my /etc/network/interfaces file to have eth0 as dhcp and then added an IP alias of eth0:1 with a static IP. I did a reboot with the network cable unplugged to make sure that it comes up on boot and everything looked good for about 10 minutes until my static IP disappeared. At this point I tried to connect the network cable and the dhcp eth0 came up fine but the static eth0:1 still did not show and was unable to ping it from my laptop. Output below along with interfaces contents. I have the network cable disconnected because the device will not always have one connected at boot and needed to test this condition. Also I need two IPs because I need to send data out to the Internet and won’t always know the IP scheme that is being used and also need to connect to a local device using a 192.168.1.x IP. This problem seems similar to this one https://unix.stackexchange.com/questions/211215/mysterious-disappearing-static-ip-address-on-wifi-interface-under-debian other than I’m using the on-board network port and I didn’t see wicd running on my system.

It appears that so far I am able to get the IP to stick by using the command “ip addr add 192.168.1.100/24 dev eth0”. I then created a shell script and a service that runs the shell script at boot.

I am no Linux expert but have what appears to be a workaround for something that I should have been able to do in the /etc/network/interfaces file. Am I missing something in my interfaces file that would make this work or is the shell script/service the best way to accomplish this task?

I’m sorry if this is more of a Linux question than a Beaglebone question but since the Beaglebone comes stock with Linux and I am using a Beaglebone I thought I would post it here.

*************************** network cable disconnected ***************************
debian@beaglebone:~$ uname -a
Linux beaglebone 4.4.91-ti-r133 #1 SMP Tue Oct 10 05:18:08 UTC 2017 armv7l GNU/Linux

debian@beaglebone:~$ date
Tue Oct 10 12:09:14 UTC 2017

debian@beaglebone:~$ ip addr show eth0
4: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 11:22:33:44:55:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0:1
valid_lft forever preferred_lft forever

debian@beaglebone:~$ date
Tue Oct 10 12:21:32 UTC 2017

debian@beaglebone:~$ ip addr show eth0
4: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 11:22:33:44:55:bb brd ff:ff:ff:ff:ff:ff

*************************** connected network cable ***************************
debian@beaglebone:~$ ip addr show eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 11:22:33:44:55:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.254.212/24 brd 192.168.254.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::3ad2:69ff:fe74:63bf/64 scope link
valid_lft forever preferred_lft forever

*************************** /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

The primary network interface

auto eth0
iface eth0 inet dhcp

auto eth0:1
iface eth0:1 inet static
address 192.168.1.100
netmask 255.255.255.0

Example to keep MAC address between reboots

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

##connman: ethX static config
#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>

##connman: WiFi

first find the connmanctl ethernet id:

connmanctl services

*AO Wired ethernet_04a316fa393f_cable

then configure it (eg, using 192.168.1.1 as gateway):

connmanctl config ethernet_04a316fa393f_cable --ipv4 manual 192.168.1.100 255.255.255.0 192.168.1.1 --nameservers 8.8.8.8

I have not had a lot of time to dig into this more but wanted to post a quick comment about what I initially found after trying this solution.

After running the command I lost my dynamic IP and was left with the static one. I rebooted the Beaglebone and had my dynamic IP back but lost my name resolution. I was unable to ping the static IP I have set on my laptop (might be a firewall issue) but was able to ping google (using ip not name). My laptop is connected to wifi and a wired network switch that has internet access which my Beaglebone is connected to and I was able to ping the WIFI address but not the static IP on my laptop but I was successful in pinging the Beaglebone from my laptop.

connmanctl config ethernet_38d2697463bf_cable --ipv4 manual 192.168.1.100 255.255.255.0 192.168.1.1 --nameservers 8.8.8.8

ip addr show eth0

4: eth0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 38:d2:69:74:63:bf brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0:1
valid_lft forever preferred_lft forever
inet6 fe80::3ad2:69ff:fe74:63bf/64 scope link
valid_lft forever preferred_lft forever

$ ping www.google.com
ping: www.google.com: Temporary failure in name resolution

$ ping 172.217.0.4
PING 172.217.0.4 (172.217.0.4) 56(84) bytes of data.
64 bytes from 172.217.0.4: icmp_seq=1 ttl=54 time=10.4 ms
64 bytes from 172.217.0.4: icmp_seq=2 ttl=54 time=10.4 ms
64 bytes from 172.217.0.4: icmp_seq=3 ttl=54 time=10.6 ms
64 bytes from 172.217.0.4: icmp_seq=4 ttl=54 time=11.0 ms
64 bytes from 172.217.0.4: icmp_seq=5 ttl=54 time=10.8 ms
64 bytes from 172.217.0.4: icmp_seq=6 ttl=54 time=10.8 ms
64 bytes from 172.217.0.4: icmp_seq=7 ttl=54 time=10.3 ms
^C
— 172.217.0.4 ping statistics —

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=15.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=57 time=17.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=57 time=15.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=57 time=15.2 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=57 time=15.8 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=57 time=15.1 ms
^C
— 8.8.8.8 ping statistics —