Inspect MTU in /sys/class/net
In this step, you will explore the /sys
filesystem to find the MTU value. The /sys
filesystem is a virtual filesystem that provides an interface to kernel data structures. It allows you to inspect and sometimes modify kernel parameters and device information.
Network interface information, including the MTU, is exposed through the /sys/class/net
directory. Each network interface on your system will have a subdirectory here.
Open your terminal if it's not already open.
First, let's list the contents of the /sys/class/net
directory to see the available network interfaces. Type the following command and press Enter:
ls /sys/class/net/
You should see a list of network interfaces, similar to the output of ip link show
or ifconfig
. In this environment, you will likely see eth0
and lo
.
eth0 lo
Now, let's look inside the directory for our primary interface, eth0
. Type the following command and press Enter:
ls /sys/class/net/eth0/
This will show you a list of files and directories that contain information about the eth0
interface.
addr_assign_type broadcast device ifindex mtu phys_port_id speed
address carrier dormant iflink napi_defer_hard_irqs phys_port_name statistics
addr_len carrier_changes duplex link_mode netdev_group power subsystem
bonding_slave carrier_up_count flags lower_ operstate proto_down_reason tx_queue_len
bridge_slave dev_id gro_flush_timeout name_assign_type perms qdisc type
Notice the file named mtu
. We can read the content of this file to get the MTU value. Use the cat
command to display the content of the mtu
file. Type the following command and press Enter:
cat /sys/class/net/eth0/mtu
You should see the MTU value printed to the terminal, which should be 1500
.
1500
This method of checking the MTU by reading the /sys
file provides a direct way to access kernel-level information about the network interface.
You have now successfully checked the MTU using three different methods: ip link show
, ifconfig
, and by inspecting the /sys
filesystem. This demonstrates that there are often multiple ways to achieve the same task in Linux.
Click Continue to complete this lab.