You can use hostname command :
ipaddr=$(hostname -I)
-i, --ip-address
:
Display the IP address(es) of the host. Note that this works only if the host name can be resolved.
-I, --all-ip-addresses
:
Display all network addresses of the host. This option enumerates all configured addresses on all network interfaces. The loopback interface and IPv6 link-local addresses are omitted. Contrary to option -i, this option does not depend on name resolution. Do not make any assumptions about the order of the output.