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

6 Ways to Elegantly Handle Objects in JavaScript

Table of contents Preface 1. Object.freeze() 2. O...

Summary of methods for querying MySQL user permissions

Introduce two methods to view MySQL user permissi...

In-depth explanation of various binary object relationships in JavaScript

Table of contents Preface Relationships between v...

How to add fields and comments to a table in sql

1. Add fields: alter table table name ADD field n...

How to obtain and use time in Linux system

There are two types of Linux system time. (1) Cal...

How to set the style of ordered and unordered list items in CSS

In an unordered list ul>li, the symbol of an u...

N ways to align the last row of lists in CSS flex layout to the left (summary)

I would like to quote an article by Zhang Xinxu a...

Solution to VMware virtual machine no network

Table of contents 1. Problem Description 2. Probl...

Detailed explanation of MySQL's MERGE storage engine

The MERGE storage engine treats a group of MyISAM...

Using the outline-offset property in CSS to implement a plus sign

Assume there is such an initial code: <!DOCTYP...

Summary of HTML Hack Tags in IE Browser

Copy code The code is as follows: <!--[if !IE]...

Implementation code of short video (douyin) watermark removal tool

Table of contents 1. Get the first link first 2. ...

Detailed explanation of mysql user variables and set statement examples

Table of contents 1 Introduction to user variable...

MySQL 5.7.18 free installation version configuration tutorial

MySQL 5.7.18 free installation version installati...

Introduction to SSL certificate installation and deployment steps under Nginx

Table of contents Problem description: Installati...