server – FromHostneme to the address

Can someone help me with this:
From / etc / hostname where for example something like this
4-125 or 4-10
and from / etc / network / interfaces where it will be something like this

source /etc/network/interfaces.d/*

auto what
iface what inet loopback

auto enp0s3
iface enp0s3 inet static
address 192.168
mask 255.255.254.0
gateway 192.168.4.1
dns-nameserver 8.8.8.8 1.1.1.1

Do this auotomatical with bash or a command

source /etc/network/interfaces.d/*

auto what
iface what inet loopback

auto enp0s3
intereset enp0s3
address 192.168.5.125
mask 255.255.254.0
gateway 192.168.4.1
dns-nameserver 8.8.8.8 1.1.1.1