The setup is a BBBW with a USB to ethernet dongle. The aim is to have both a wireless interface as well as a wired interface. For compatibility with other hardware code, we cannot use connman services as they are not available on all platforms. As these changes will be done from configuration files sent to the device. The solution must be done programatically. We are using GO for the interpretation of the configuration files. At this time, we chose to use the /etc/network/interfaces files to effect the changes. Since the device needs to be active at all times, no reboot is permitted.
We can get the changes to be applied by a reboot (not what we want though), but a network restart does not work. The main problem we encounter is when trying to set a static address for an interface without rebooting the device.
Example: Changing the wlan0 interface static IP Initially we have one IP on wlan0
output from "ip a s":
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 50:65:83:dc:43:cc brd ff:ff:ff:ff:ff:ff
inet 192.168.0.90/24 brd 192.168.0.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::5265:83ff:fedc:43cc/64 scope link
valid_lft forever preferred_lft forever
ifconfig shows:
wlan0 Link encap:Ethernet HWaddr 50:65:83:dc:43:cc
inet addr:192.168.0.90 Bcast:192.168.0.255 Mask:255.255.255.0
We edit /etc/network/interfaces with :
iface wlan0 inet static
address 192.168.0.91
netmask 255.255.0.0
gateway 192.168.0.1
wpa-ssid SOME_SSID
wpa-psk SOME_KEY
Then we issue :
sudo ifdown wlan0
sudo ifup wlan0
sudo service networking restart
And we see:
ip a s :
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 50:65:83:dc:43:cc brd ff:ff:ff:ff:ff:ff
inet 192.168.0.90/24 brd 192.168.0.255 scope global wlan0
valid_lft forever preferred_lft forever
inet 192.168.0.91/24 brd 192.168.0.255 scope global secondary wlan0
valid_lft forever preferred_lft forever
inet6 fe80::5265:83ff:fedc:43cc/64 scope link
valid_lft forever preferred_lft forever
ifconfig:
wlan0 Link encap:Ethernet HWaddr 50:65:83:dc:43:cc
inet addr:192.168.0.90 Bcast:192.168.0.255 Mask:255.255.255.0
As you can see the new IP address is taken as a secondary IP. Ifconfig only shows the primary IP and not the secondary IP. We can connect to the device with both address but the presence of the old IP address is not acceptable.
Is there a correct way to do this from system files edits or even system calls (bash commands)
Is this secondary IP behaviour only a BBB thing or is this a Linux one ?