Ubuntu system network configuration file analysis and description, record the research process and some configuration situations, by the way, learn about the network environment configuration under Linux.
Simple Application Server USD1.00 New User Coupon
* Only 3,000 coupons available.
* Each new user can only get one coupon(except users from distributors).
* The coupon is valid for 30 days from the date of receipt.
Network profile This file configures 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
In the configuration of /etc/network/interfaces there may be some original configurations, such as
auto lo
iface lo inet loopback
These two lines indicate that the lo interface is automatically configured when the auto lo system starts, and then a local loopback address is configured 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 respectively represent the IP, network number, mask, broadcast address and gateway of the eth0 interface.
If you want to configure DHCP to automatically obtain an IP address
auto eth0
iface eth0 inet dhcp
For more configuration content, see man interfaces
Go to the /etc/network directory and you will find many interesting directories
if-down.d before network shutdown
if-post-down.d After the network is closed
if-pre-up.d before network establishment
if-up.d network is established
These directories belong to the network configuration implemented by Debian. When an if-up occurs, the script placed in the if-up.d directory will be executed, so that it can be used to achieve some interesting things, such as if a sign-in is written Script, then you can automatically complete the sign-in when the laptop is connected to the Internet, or start the VPN after the network is connected.
Add execute 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 a script here in /etc/NetworkManager/dispatcher.d/, which can also do the same thing, but it needs to rely on NetworkManager.
Configure DNS
The DNS configuration file is in the /etc/resolv.conf file, generally
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 network
sudo /etc/init.d/networking restart
sudo /etc/init.d/network-manager restart
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.