If the ifconfig
command does not show the IPv4 address of a network interface on your Linux system, it could be because the interface is not configured to use IPv4.
To check the status of a network interface and its configured addresses, you can use the ip
command with the addr
option.
Here's an example of how you can use the ip
command to display the IPv4 address of a network interface:
ip addr show interface_name | grep inet
Replace interface_name
with the name of your network interface, such as eth0
or wlan0
.
This command will display the IPv4 address and subnet mask of the interface, as well as the status of the interface (up or down).
If the interface is not configured to use IPv4, you will not see any output from this command.
To configure an interface to use IPv4, you can use the ip
command with the addr
and add
options. For example:
ip addr add IP_ADDRESS/SUBNET_MASK dev interface_name
Replace IP_ADDRESS
with the desired IPv4 address for the interface, and SUBNET_MASK
with the appropriate subnet mask.
Keep in mind that this configuration will not be persisted after a reboot. To make the configuration permanent, you will need to add the ip
command to a startup script or modify the interface configuration file in the /etc/network
directory.
For more information about the ip
command and its available options, you can consult the ip
man page or use the ip --help
command.