Networking Basics on Linux with ifconfig and ip
The ifconfig and ip commands are two of the most important commands for managing network interfaces on Linux. ifconfig is the traditional command for configuring and displaying network interface information, while ip is a newer command that provides a more comprehensive set of features.
ifconfig
The ifconfig command can be used to:
- Display the status of a network interface
- Configure the IP address, netmask, and other settings of a network interface
- Bring up or down a network interface
To display the status of a network interface, simply run the ifconfig command without any arguments. This will display a list of all the network interfaces on your system, along with their current status.
ifconfig
To configure the IP address, netmask, and other settings of a network interface, use the following syntax:
ifconfig interface IP_address netmask gateway [options]
For example, to set the IP address of the eth0 interface to 192.168.1.100, the netmask to 255.255.255.0, and the gateway to 192.168.1.1, you would run the following command:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1
To bring up or down a network interface, use the following syntax:
ifconfig interface up|down
For example, to bring up the eth0 interface, you would run the following command:
ifconfig eth0 up
To bring down the eth0 interface, you would run the following command:
ifconfig eth0 down
ip
The ip command is a more comprehensive command for managing network interfaces on Linux. It can be used to:
- Display the status of a network interface
- Configure the IP address, netmask, and other settings of a network interface
- Bring up or down a network interface
- Add or remove routes
- Set up network filters
To display the status of a network interface, use the following syntax:
ip -s link
This will display a list of all the network interfaces on your system, along with their current status.
To configure the IP address, netmask, and other settings of a network interface, use the following syntax:
ip addr add IP_address/netmask dev interface
For example, to set the IP address of the eth0 interface to 192.168.1.100, the netmask to 255.255.255.0, and the gateway to 192.168.1.1, you would run the following command:
ip addr add 192.168.1.100/255.255.255.0 dev eth0
To bring up or down a network interface, use the following syntax:
ip link set interface up|down
For example, to bring up the eth0 interface, you would run the following command:
ip link set eth0 up
To bring down the eth0 interface, you would run the following command:
ip link set eth0 down
To add or remove routes, use the following syntax:
ip route add|del IP_address/netmask via gateway
For example, to add a route to the 192.168.2.0/24 network via the 192.168.1.1 gateway, you would run the following command:
ip route add 192.168.2.0/24 via 192.168.1.1
To set up network filters, use the following syntax:
ip link add|del link_device type bridge
For example, to add a bridge device named br0, you would run the following command:
ip link add br0 type bridge
```# Networking Basics On Linux With Ifconfig And Ip
## Executive Summary
In this article, we will explain two of the most commonly used command line networking utilities on Linux: **ifconfig** and **ip**. These utilities provide information about the network configuration of the system, and can be used to configure network interfaces. We will cover the basic usage of these utilities, as well as some of the more advanced features that they offer.
## Introduction
Networking is an essential part of any modern operating system. It allows computers to communicate with each other, and to access resources on other computers. The Linux operating system provides a number of powerful networking tools, including **ifconfig** and **ip**. These utilities can be used to configure and manage network interfaces, and to troubleshoot network problems.
## Using ifconfig
**ifconfig** is a command line utility that displays information about the network interfaces on the system. It can also be used to configure network interfaces, such as changing the IP address or the network mask.
**Some of the most important options that ifconfig** can use include:
- **-a:** Displays information about all network interfaces on the system, even if they are not currently active.
- **-s:** Displays a summary of the network configuration of the system.
- **-v:** Displays more verbose information about the network configuration of the system.
- **up:** Brings up a network interface.
- **down:** Brings down a network interface.
- **addr:** Assigns an IP address to a network interface.
- **netmask:** Assigns a network mask to a network interface.
## Using ip
**ip** is a command line utility that provides more advanced networking functionality than **ifconfig**. It can be used to configure network interfaces, manage routing tables, and troubleshoot network problems.
**Some of the most important options that ip** can use include:
- **-a:** Displays information about all network interfaces on the system, even if they are not currently active.
- **-s:** Displays a summary of the network configuration of the system.
- **-v:** Displays more verbose information about the network configuration of the system.
- **link:** Displays information about the link layer of a network interface.
- **addr:** Displays information about the IP addresses of a network interface.
- **route:** Displays the routing table of the system.
## Conclusion
**ifconfig** and **ip** are two powerful command line utilities that can be used to configure and troubleshoot network problems on Linux systems. By understanding the basics of these utilities, you can use them to keep your network running smoothly.
## Keyword Phrase Tags
* Linux networking
* ifconfig
* ip
* network configuration
* troubleshooting network problems
This command is very useful in many networking scripts, and it’s good to have a basic understanding on how to use it.
Is this working for latest kernels? As far as I know, the command ‘ifconfig’ was deprecated ages ago.
The ip command is a more modern alternative to ifconfig, which is no longer maintained.
I think that the ifconfig command is more user friendly than the ip command.
lol, I’m sure that ifconfig was deprecated for a reason.
I can’t believe that people are still using ifconfig in 2023.
I’m not sure why you would want to use ifconfig when there are better alternatives available.
This is a great tutorial on how to use ifconfig. Thanks for sharing!
I’m not sure if this is the best way to do this. There might be a better way to do this, but I’m not sure what it is.