Configuring IPv4 permanently
In the previous section we configured the network interface, but this configuration is only valid while the system is up and running. A reboot will clear this configuration, unless you take steps to make sure that it is configured on each boot. This configuration will be specific to the distribution that you are running, although most distributions fall under either the Debian or Red Hat methods.
How to do it…
Let' see how it works in Debian/Ubuntu:
- Add
eth0
configuration to/etc/network/interfaces
:auto eth0 iface eth0 inet static address 10.0.0.1 netmask 255.255.255.0
- Bring up the network interface:
# ifup eth0
Let' see how it works in Red Hat/CentOS:
- Add the
eth0
configuration to/etc/sysconfig/network-scripts/ifcfg-eth0
:DEVICE=eth0 BOOTPROTO=none ONBOOT=yes NETWORK=10.0.0.0 NETMASK=255.255.255.0 IPADDR=10.0.0.1 USERCTL=no
- Bring up the network interface:
# ifup eth0
How it works…
Linux distributions are configured through init
systems, such as Upstart, SystemD, or SysVInit. During the initialization process, the interfaces, or ifcfg-eth0
files, are used as a configuration for the networking setup scripts. These scripts then use the same ip
commands, or possibly ifconfig
commands to set up and bring up the network interface.