The ifcfg
command is used to set network interface parameters in Linux. It is used to configure network interfaces, including Ethernet, Wi-Fi, and virtual interfaces. This command is typically used by system administrators to configure network settings on Linux servers and workstations.
Overview
The ifcfg
command is used to configure network interfaces in Linux. It is typically used to set IP addresses, netmasks, gateways, and other network settings. The command is used to create and modify configuration files for network interfaces. These files are typically stored in the /etc/sysconfig/network-scripts/
directory.
To use the ifcfg
command, you must have root privileges. The command is typically run from the command line using a text editor such as vi or nano.
Syntax
The syntax for the ifcfg
command is as follows:
ifcfg [interface] [options]
Where interface
is the name of the network interface you want to configure and options
are the configuration options you want to set.
Examples
Here are some examples of how to use the ifcfg
command:
ifcfg eth0
This command displays the configuration for the eth0
network interface.
ifcfg eth0:1
This command displays the configuration for the eth0:1
virtual network interface.
ifcfg eth0 BOOTPROTO=static IPADDR=192.168.1.10 NETMASK=255.255.255.0 GATEWAY=192.168.1.1
This command sets the IP address, netmask, and gateway for the eth0
network interface.
Use Cases
The ifcfg
command is used in a variety of use cases, including:
- Configuring network interfaces on Linux servers and workstations.
- Setting up virtual network interfaces.
- Configuring network settings for specific applications or services.
OPTIONS
Here are the available options for the ifcfg
command:
Option | Description |
---|---|
BOOTPROTO | Specifies the boot protocol for the network interface. Valid values are dhcp , bootp , static , and none . |
DEVICE | Specifies the name of the network interface. |
HWADDR | Specifies the MAC address of the network interface. |
IPADDR | Specifies the IP address of the network interface. |
NETMASK | Specifies the netmask of the network interface. |
GATEWAY | Specifies the default gateway for the network interface. |
DNS1 | Specifies the primary DNS server for the network interface. |
DNS2 | Specifies the secondary DNS server for the network interface. |
DOMAIN | Specifies the domain name for the network interface. |
ONBOOT | Specifies whether the network interface should be started automatically at boot time. Valid values are yes and no . |
TYPE | Specifies the type of network interface. Valid values are Ethernet , Wireless , and Bond . |
USERCTL | Specifies whether non-root users are allowed to control the network interface. Valid values are yes and no . |
TROUBLESHOOTING TIPS
Here are some troubleshooting tips for common issues with the ifcfg
command:
- If you are having trouble configuring a network interface, check that the configuration file is in the correct directory and that it has the correct permissions.
- If you are having trouble connecting to a network, check that the network settings are correct and that the network is available.
- If you are having trouble with a virtual network interface, check that the virtual interface is configured correctly and that any necessary kernel modules are loaded.
NOTES
- The
ifcfg
command is typically used on Red Hat-based Linux distributions, such as CentOS and Fedora. Other distributions may use different commands or configuration files for network interface configuration. - The configuration files for network interfaces are typically stored in the
/etc/sysconfig/network-scripts/
directory.