How to setup IPv4 on Ethernet network interface on Linux
All network interface settings in Debian/Ubuntu and distributions based on them, such as Raspbian, Kali, etc. produced in the configuration file /etc/network/interfaces. Today we will get acquainted with the basic configuration of network interfaces. To do this, open the file /etc/network/interfaces and see what is in it.
loopback interface
auto loiface lo inet loopback
The following configuration allows the wlan0 interface to start automatically and receive network settings via DHCP:
allow–hotplug wlan0iface eth0 inet dhcp
The manual method says that there are no default settings for the eth0 interface. The eth0 interface can be further configured manually, or by scripts from the /etc/network/if-*.d directories.
auto eth0iface eth0 inet manual
and the last method is static. In it, we set all the network settings manually. Some options may be redundant.
auto eth1iface eth1 inet staticaddress 192.168.1.9netmask 255.255.255.0network 192.168.1.0broadcast 192.168.1.255gateway 192.168.1.1nameserver 192.168.1.1nameserver 8.8.8.8
address – IP address (in the example: 192.168.1.9)
netmask – netmask (in the example: 255.255.255.0, network / 24)
network-used network (in the example: 192.168.1.0)
broadcast – broadcast address (in the example: 192.168.1.255)
gateway – gateway address (in the example: 192.168.1.1)
nameserver – list of DNS servers (in the example: 192.168.1.1 and 8.8.8.8)
When using the dhcp or static methods, you can specify the MAC address:
hwaddress ether 03:53:55:17:98:AB