Even though NetworkManager is the default network configuration stack for Enterprise Linux, it still supports static network configuration files. In these files, learn how you can name the interface and avoid the automatic consistent naming of systemd. Also, set per-interface DNS settings, default routes, override MAC addresses, and tailor specific interface settings such as the MTU.
- [Instructor] Network interface configuration files control the interfaces for individual network devices. As the system boots, these files are read and the network interfaces are configured or possible ignored depending on the configuration. These files are stored in /etc/sysconfig/network-scripts and named ifcfg-name where name is the name of the network interface. For instance, the configuration file for the enp0s3 network interface would be /etc/sysconfig/network-scripts/ifcfg-enp0s3.
The network interface is also named inside of the file as well. Generally it's a good idea to have them match. These scripts are for all network interface configuration including dynamic and manual configs. A dynamic config may have only a few lines in it specifying the name of the device and the boot protocol of dhcp. This example specifies that it should be enabled at boot and used as dhcp for configuration. To create a static interface configuration, we'll change the boot protocol to none. In this case, we're using a 24-bit subnet mask in the prefix line.
If we wanted to insert the net mask as dotted notation, we could write it as netmask equals 255.255.255.0. The last line is the statically assigned IP version four address. There are a lot of different options you can add to this file. Let's go over some of the more common ones. Device specifies the network device to configure. IPADDR is for the IP version four address. IPV6ADDR is for the IP version six address. The HWADDR option specifies which network interface to configure if you have more than one.
This is used to identify the network interface. The MACADDR option assigns a new MAC address overwriting the one on the card. BOOTPROTO assigns the boot protocol and can be none for static assignments, bootp for older dynamic assignments, and dhcp for newer dynamic networks. ONBOOT specifies whether the network interface should be enabled at boot. IPV6INIT specifies whether IP version six should be enabled or not. The next couple needs some explanation. The global DNS name server file is /etc/resolv.conf.
However, enterprise Linux allows interface specific DNS servers using the DNS one equals or DNS two equals options. We would specify the DNS server addresses here. To keep these options interface specific, we need to set peer DNS to yes. If we change it to no, these DNS servers are then copied to the global /etc/resolv.conf file. Netmask and prefix are both used to set the network mask. Only one is required. If you want to enter the netmask in dotted notation, use netmask equals.
If you want to use CIDR, then use PREFIX equals. The next two items are for whether you want network manager controlling the interface or whether you want non-root users to be able to control it. There are many other options used to tune network interfaces and provide more control. The Red Hat Enterprise Linux Six Deployment Guide actually has more information on these files than the Red Hat Enterprise Linux Seven Networking Guide. So reference that. You might want to note that if you change or edit these configuration files, you'll need to notify network manager. One way to do this is to use nmcli to reload the configuration.
In a terminal, you would type nmcli space c for configuration space reload and hit enter.
- Gathering network information
- Ensuring connectivity with ping
- Querying DNS servers with dig
- Changing hostname, IP address, and more
- Configuring networking
- Connecting to SSH
- Configuring SSH clients
- Authenticating and restricting access with SSH
- Optimizing SSH for speed