[From] rotate.
There are two ways to modify the network configuration in Ubuntu: network-manager and/etc/network/interfaces, the network-manager file conflicts with the/etc/network/interfaces file.
1 Server version
In Ubuntu Server, because only the command line mode exists, you can only modify the configuration file to set network parameters.
/Etc/network/interfaces. The specific settings are as follows:
(1) modify the IP address of Ubuntu Server
Open/etc/network/interfaces:
sudo vim /etc/network/interfaces
Add the following statement:
Auto eth0iface eth0 inet staticaddressxxx. xxx # IP address netmask xxx. xxx # subnet mask gateway xxx. xxx # gateway
(2) modify the DNS of Ubuntu Server
Open/etc/resolv. conf
sudo vim /etc/resolv.conf
Change to the following content:
Search localdomain # If this Server is a DNS Server, add this sentence. If not, do not add nameserver 172.16.3.4 # the DNS Server you want to modify to: DNSnameserver 172.16.3.3 #
(3)
Ubuntu Server restarts the network
Add the command to restart the network configuration in rc. local:
sudo /etc/init.d/networking restart
2. Desktop version
In the Desktop version, you can modify/etc/network/interfaces for configuration. You can also directly configure it in network-manager. Use interfaces to modify the Server version. The network-manager configuration is intuitive and can be performed step by step as prompted. If you are interested, you can Google or Baidu on your own.
If interfaces is modified and network-manager (nm) is configured, you will find some inexplicable problems:
- The network settings in interfaces and nm are different. What is the actual IP address of the system?
- Sometimes, the network connection icon in the upper-right corner of the interface is lost.
- Why can't I access the network even if the correct network settings are configured in nm?
In fact, we need to know the relationship between interfaces and nm, and these problems are not difficult to explain.
Network-manager and/etc/network/interfaces:
- When no third-party network management tools (such as nm) exist in the system, the system uses parameters in the interfaces file by default for network configuration.
- After nm is installed in the system, nm takes over the network configuration of the system by default, and uses its own network configuration parameters for configuration.
- However, if you manually modify the interfaces file after the nm is installed (the nm is installed by default in the Desktop version), the nm will automatically stop managing the system network and change the system usage.
Configure the parameters in the interfaces file. In this case, modify the parameter in nm without affecting the actual network configuration of the system. To make the configuration within the nm take effect, you must re-enable the nm.
Take over the network configuration of the system.
Now that we know the working relationship between the two, let's look at the above three questions:
- It depends on whether the nm takes over. If the system does not, the actual IP settings of the system are subject to interfaces. Otherwise, take the value in nm as the standard.
- When nm stops taking over, the network connection icon is lost.
- It is also a matter of taking over. If you want to directly use interfaces for network configuration in the Desktop version, you 'd better delete network-manager.
.
Network-manager
If you want to continue using nm for network configuration after the above problem occurs, you need to perform the following operations:
Sudo service network-managerstop # Stop the nm service sudo rm/var/lib/NetworkManager. state # Remove the state file sudo gedit/etc/NetworkManager/nm-system-settings.conf # Open the configuration file # There is a line in it: managed = true # If you manually change/etc/network/interfaces, nm will change this line to: managed = false # Change false to truesudo service network-manager start