Linux /etc/network/interfaces configuration interface method

Linux /etc/network/interfaces configuration interface method

The /etc/network/interfaces file in Linux is used to configure network interfaces.

Initialize Ethernet Interface

Most network interface configurations can be done in /etc/network/interfaces. For example, configure a static IP (DHCP) for the network card, set routing information, configure the IP mask, set the default route, etc.

PS: If you want to automatically start the network port when the system starts, you need to add a line of auto, as shown in the example below.

1. Use a dynamic IP address

auto eth0
iface eth0 inet dhcp

2. Use a static IP address

auto eth0
iface eth0 inet static
  address 192.168.1.100
  netmask 255.255.255.0
  gateway 192.168.1.1
# network 192.168.1.0
# broadcast 192.168.1.255

The default values ​​for network and broadcast are usually sufficient.

3. Check the routing table

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

route -n does not resolve names.

The above is the relevant content compiled by the editor of 123WORDPRESS.COM. Thank you for your learning and support.

You may also be interested in:
  • Detailed explanation of Linux DMA interface knowledge points
  • Demonstration of building ElasticSearch middleware and common interfaces under centos7 in Linux system
  • How to view available network interfaces in Linux
  • The Linux system uses Python to monitor the network interface to obtain network input and output
  • Basic Introduction to BSD Socket Development in Linux
  • Basic Introduction to BSD Socket Development in Linux Operating System

<<:  SQL serial number acquisition code example

>>:  Native js to achieve puzzle effect

Recommend

Detailed explanation of Promises in JavaScript

Table of contents Basic usage of Promise: 1. Crea...

How to find and delete duplicate records in MySQL

Hello everyone, I am Tony, a teacher who only tal...

Bootstrap3.0 study notes table related

This article mainly explains tables, which are no...

Docker container accesses the host's MySQL operation

background: There is a flask project that provide...

MySQL online deadlock analysis practice

Preface I believe that everyone has had a simple ...

Usage and execution process of http module in node

What is the role of http in node The responsibili...

A magical MySQL deadlock troubleshooting record

background Speaking of MySQL deadlock, I have wri...

Solution to blank page after Vue packaging

1. Solution to the problem that the page is blank...

JavaScript regular verification password strength implementation method

exhibit design Password strength analysis The pas...

A brief analysis of CSS :is() and :where() coming to browsers soon

Preview versions of Safari (Technology Preview 10...

Vue implements form validation function

This article mainly describes how to implement fo...

52 SQL statements to teach you performance optimization

1. To optimize the query, try to avoid full table...