Operations 5 min read

Linux Network Configuration Commands: ifconfig, ifup/ifdown, and route

The article explains how to use the Linux commands ifconfig, ifup/ifdown, and route for querying and modifying network interfaces, IP addresses, subnet masks, MTU values, and routing tables, providing example usages and practical tips for immediate effect.

php中文网 Courses
php中文网 Courses
php中文网 Courses
Linux Network Configuration Commands: ifconfig, ifup/ifdown, and route

This article introduces three Linux network configuration commands— ifconfig , ifup/ifdown , and route —and demonstrates how to query and modify network interfaces, IP addresses, subnet masks, MTU values, and routing tables.

1. ifconfig

The ifconfig command can display or set network interface parameters such as IP address, netmask, broadcast address, and MTU. It requires the net-tools package.

# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.220  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::1733:cf21:906d:57af  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:84:5b:d0  txqueuelen 1000  (Ethernet)
        RX packets 9946  bytes 10315936 (9.8 MiB)
        TX packets 2208  bytes 186213 (181.8 KiB)
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
…

From the output you can obtain the interface name, IP address, netmask, broadcast address, and other statistics.

Examples:

# ifconfig eth0 192.168.1.222

This changes only the IP address; the broadcast address updates automatically.

# ifconfig eth0 192.168.2.222 netmask 255.255.240.0 mtu 1000

Changes IP, subnet mask, and MTU in one command. After modifications, restart the network service to apply changes.

2. ifup / ifdown

When you edit the network configuration file (e.g., /etc/sysconfig/network-scripts/eth0 ) and want the changes to take effect immediately, use:

ifdown eth0
ifup eth0

Alternatively, you can restart all interfaces with:

/etc/init.d/network restart

3. route

The route command displays or modifies the kernel routing table.

Common options:

-n : display numeric IP addresses without DNS lookup (faster).

-ee : show detailed information.

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.19.255.253  0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0

Key fields:

Destination – network address.

Genmask – subnet mask; together they define a network.

Gateway – next-hop address (0.0.0.0 means direct delivery).

Flags – e.g., U (route is up), G (uses a gateway).

networklinuxshellRouteifconfigifdownifup
php中文网 Courses
Written by

php中文网 Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.