Static IP Address
It is sometimes desirable to provide static IP configuration for network interface instead of relying on DHCP.
Using /etc/network/interfaces
Edit /etc/network/interfaces and add configuration sections for network interfaces. The example below configures eth0
auto eth0 iface eth0 inet static address 192.0.2.7 netmask 255.255.255.0 gateway 192.0.2.254
Configure connman interface blacklist
The default Yocto network manager is connman. It is a service to manage network connections in embedded devices. Connman may override the settings in /etc/network/interfaces unless configured to blacklist certain interfaces. For example, after configuring eth0 and eth1 in /etc/network/interfaces, create /etc/connman/main.conf and add the following:
[General] NetworkInterfaceBlacklist=eth0,eth1
Configure static IP using connman
Instead of using /etc/network/interfaces one can use connman command line interface to configure static IP. To create initial configuration the relevant interface should be connected to the network.
To get the list of connections run
# connmanctl services
For example:
root@imx7-var-som:~# connmanctl services *AO Wired ethernet_0eb31468dcc9_cable
Wired Ethernet connection would be shown as ethernet_<mac_address>_cable.
To configure static IP, run
# connmanctl <service> --ipv4 manual <ip address> <netmask> <gateway>
For example:
# connmanctl ethernet_0eb31468dcc9_cable --ipv4 manual 192.0.2.7 255.255.255.0 192.0.2.254