The /etc/network/interfaces
file is used to configure network interfaces on Ubuntu Linux systems. The file contains a list of network interfaces and their configuration settings.
Here is an example of the /etc/network/interfaces
file that configures a static IP address for the eth0
interface:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8 8.8.4.4
In this example, the eth0
interface is configured with a static IP address of 192.168.1.100
, a netmask of 255.255.255.0
, and a default gateway of 192.168.1.1
. The dns-nameservers
option specifies the DNS servers to use for name resolution.
To configure the eth0
interface to use DHCP, you can set the iface
option to dhcp
and remove the address
, netmask
, and gateway
options: