I encountered a strange network problem today. I recorded the research process and some configuration situations, and learned about the network environment configuration under Linux. Network Configuration Files This file configures the network card information vi /etc/network/interfaces auto lo iface lo inet loopback # Configure eth0 dhcp to obtain IP address auto eth0 iface eth0 inet dhcp The role of configuration There may be some configurations in /etc/network/interfaces, such as auto lo iface lo inet loopback These two lines indicate that the auto lo system automatically configures the lo interface when it starts, and then configures a local loopback address for the lo interface. If you want to configure a static address for the network card auto eth0 iface eth0 inet static address 192.168.2.100 network 192.168.2.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 The following lines represent the IP, network number, mask, broadcast address and gateway of the eth0 interface respectively. If you want to configure DHCP to automatically obtain an IP address auto eth0 iface eth0 inet dhcp For more configuration information, see man interfaces Go to the /etc/network directory and you will find many interesting directories. if-down.d if-post-down.d if-pre-up.d if-up.d These directories are all network configurations implemented in Debian. When if-up occurs, the scripts placed in the if-up.d directory will be executed. This can be used to achieve some interesting things. For example, if you write a sign-in script, you can automatically sign in when the laptop is connected to the Internet, or start the VPN after connecting to the Internet. Add execute permissions chmod 755 /etc/network/if-up.d/YOUR_SCRIPT Note that scripts are executed in lexicographic order. Another way is to define the script in /etc/NetworkManager/dispatcher.d/, which can do the same thing, but it depends on NetworkManager. Configure DNS The DNS configuration file is in the /etc/resolv.conf file, which is usually search domain nameserver 127.0.0.53 Restart the network card sudo ifup eth0 sudo ifdown eth0 # or sudo ifconfig eth0 down sudo ifconfig eth0 up Restart the network sudo /etc/init.d/networking restart sudo /etc/init.d/network-manager restart Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Install mysql 5.6 from yum source in centos7.4 system
>>: Using JS timer to move elements
1. Introduction to mysqldump mysqldump is a logic...
All-round system monitoring tool dstat dstat is a...
In web development, you often encounter characters...
First, let's explain the network setting mode...
background The amount of new data in the business...
Table of contents introduction Ideas Establish ID...
# The following examples are for x64-bit runtime ...
Students who use Ansible know that Ansible only s...
Method 1: Use the SET PASSWORD command mysql -u r...
1 Introduction In the article "Start Postgre...
<meta http-equiv="x-ua-compatible" co...
This article mainly introduces the example of imp...
Special statement: This article is translated bas...
Table of contents Mixin Mixin Note (duplicate nam...
Table of contents Object Object Definition Iterat...