The network interface config file is located at /etc/network/interfaces
The default setting of the interfaces file is
# 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
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
Modify the setting as per below after the entry iface eth0 inet. I think the below setting is clear enough, don’t have to explain what is IP address, broadcast and gateway.
$ sudo su -
[sudo] password for xxx: (enter your password here for su to root)
$ nano /etc/network/interfaces
iface eth0 inet static
$ service networking restart
Note: The /etc/resolv.conf name server entries will be replaced/updated with the dns-nameservers setting in /etc/network/interfaces after rebooting. Therefore, no need to modify /etc/resolv.conf with the name server entries again.
Changing Hostname and Fully Qualified Domain Name (FQDN)
The host name file is located at /etc/hostname, you can modify the entry in this file to the required hostname. Do note that you will also have to modify the hostname in /etc/hosts file for the 127.0.0.1 entry, if not your hostname and your hosts file entries will be different.
The command service networking restart doesn’t seem to update the hostname changes, best to reboot the system.