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