Network Interfaces in Linux
/etc/network/interfaces
This article will look at the complete syntax explanation in
Debian and its derivatives .
The file /etc/network/interfaces
allows you to assign static and dynamic IP addresses to interfaces, configure routing information, default gateway, masquerade network bindings, etc.
Physical and virtual network interfaces in Linux
TCP/IP
The implementation defines an interface that masks variations in network provisioning and reduces network communication to the exchange of data with an abstract entity.
The Linux kernel distinguishes between physical and virtual network interfaces.
ifconfig
Use commands to diagnose and configure network interfaces
in Linux
ifconfig
Is a UNIX-like system command line program used to diagnose and configure network interfaces.
$ ifconfig
Output:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:72:4e:1a:db txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether d4:81:d7:bd:c6:ef txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 11182 bytes 1139133 (1.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11182 bytes 1139133 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.69 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 2403:3800:3217:204b:3be8:d506:7950:933c prefixlen 64 scopeid 0x0<global>
inet6 fe80::4cd5:8a62:8187:55fc prefixlen 64 scopeid 0x20<link>
inet6 2403:3800:3217:204b:9902:5eba:d521:1d6b prefixlen 64 scopeid 0x0<global>
ether 3c:f8:62:e5:d7:e2 txqueuelen 1000 (Ethernet)
RX packets 521763 bytes 557860095 (557.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 288568 bytes 61590689 (61.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
We can see that there are four network interfaces.
-
docker0
It is a docker virtual bridge interface that establishes a unique network for Docker containers, allowing them to connect. -
enp3s0
Formerly known aseth0
. This physical interface represents Ethernet. -
lo
Is a virtual network interface used primarily for diagnostics and troubleshooting, and connects to services running on localhost. -
wlp2so
It is your wifi interface.
Setting up in Linuxeth0
In the following example, 192.168.1.5
the IP address and 192.168.1.254
gateway (route) settings to eth0
(initial network interface card) are used:
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.254
dhcp
Interface settings
in Linux
Use the following command to eth0
convert to dhcp
.
auto eth0
iface eth0 inet dhcp
Edit /etc/network/interfaces
the file to create 静态
the address interface
If you would like to configure 静态
an IP address and gateway instead of using DHCP
, replace the previous instructions with the following ( change 192.168.0.8/24
and 192.168.0.1
to your actual IP address):
auto <Interface>
iface <Interface> inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Git list remote branches
Publish Date:2025/04/20 Views:54 Category:OPERATING SYSTEM
-
This article will show you how to list remote repositories from your local branch. A remote repository is a project hosted on a server, such as Github/Gitlab. git remote Allows us to use short names (aliases) to execute commands instead of
Pushing from an existing remote repository to another remote repository in Git
Publish Date:2025/04/20 Views:67 Category:OPERATING SYSTEM
-
This tutorial will teach you how to push from an existing remote repository to a different remote repository in Git. Git is a version control system used to track changes in a project directory. Git uses commits for such purposes. In Git, y
Update the repository remotely by setting
Publish Date:2025/04/20 Views:120 Category:OPERATING SYSTEM
-
In this tutorial, we will discuss how to set up the central repository as a remote for our local repository so that our branch is updated whenever the central repository changes. We should always perform this step before making edits to our
Rename Git repository
Publish Date:2025/04/20 Views:100 Category:OPERATING SYSTEM
-
In this article, we will discuss renaming Git repositories. We can explain this in different ways. It can rename the displayed name, the repository on GitHub, or the folder of the repository. We will discuss these and go through the steps w
Creating tags in a Git repository
Publish Date:2025/04/20 Views:117 Category:OPERATING SYSTEM
-
In this tutorial, we will discuss how to create tags in a Git repository. Creating tags in a Git repository In Git, we may want to mark certain commits or specific points in the history of the project repository. To do this, we can use the
Push Git tags to remote repositories
Publish Date:2025/04/20 Views:177 Category:OPERATING SYSTEM
-
If you create a git tag locally, your intention must be to share your changes with your team for easy tracking. Commit is one of the common operations to share changes. But another sharing and tracking idea added to it is Git Tags. This art
Fixed: Git Is Not Recognized as an Internal or External Command error
Publish Date:2025/04/20 Views:198 Category:OPERATING SYSTEM
-
This article discusses three methods we can use to fix "git" Is Not Recognized as an Internal or External Command when using Git in the Windows Command Prompt . This is a frequently reported error by users who prefer running Git commands on
Ignore untracked files in Git
Publish Date:2025/04/20 Views:162 Category:OPERATING SYSTEM
-
This article will discuss two methods that can be used to ignore untracked files in a Git repository. If there are multiple untracked files and folders in your local repository, running the git status command will output many lines. Let’s
Ignore everything except certain files in Git
Publish Date:2025/04/20 Views:151 Category:OPERATING SYSTEM
-
This article outlines the steps to make Git ignore all but a few files in a Git repository. The .gitignore file is a useful Git utility that allows us to tell Git which files to track and which files not to track. If you want your .gitignor