Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis and explanation of Network configuration File under Ubuntu system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Today encountered a strange network problem, record the research process and some configuration, by the way, learn the configuration of the network environment under Linux.

Network profile

This file configures the network card information vi / etc/network/interfaces

Auto loiface lo inet loopback# configure eth0 dhcp to get IP address auto eth0iface eth0 inet dhcp

The role of configuration

There may already be some configurations in the / etc/network/interfaces configuration, such as

Auto loiface lo inet loopback

These two lines indicate that the lo interface is automatically configured when the auto lo system boots, and then a local loopback (loopback) address is configured for the lo interface.

If you want to configure a static address for the network card

Auto eth0iface 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.

If you want to configure automatic acquisition of IP address DHCP

Auto eth0iface eth0 inet dhcp

For more configuration, please see man interfaces.

Go to the / etc/network directory and you will find many interesting directories.

If-down.dif-post-down.dif-pre-up.dif-up.d

These directories are network configurations implemented by Debian, and scripts placed in the if-up.d directory will be executed when if-up occurs, so that it can be used to implement some interesting things, such as if you write a check-in script, you can automatically complete the check-in when the laptop is connected to the Internet, or start VPN after networking.

Add execution permission

Chmod 755 / etc/network/if-up.d/YOUR_SCRIPT

Note that the script execution order is lexicographic alphabetical order.

Another way is to define the script here in / etc/NetworkManager/dispatcher.d/, and you can do the same thing, but you need to rely on NetworkManager.

Configure DNS

The DNS configuration file is in the / etc/resolv.conf file, which is generally

Search domainnameserver 127.0.0.53

Restart the network card

Sudo ifup eth0sudo ifdown eth0# orsudo ifconfig eth0 downsudo ifconfig eth0 up

Restart the network

Sudo / etc/init.d/networking restartsudo / etc/init.d/network-manager restart

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report