Ubuntu can not connect to the network solution Pro-test feasible experience

Suddenly found that Ubuntu cannot connect to the network, there is a question mark on the network or there is no network icon in the upper right corner; the landlord usually solves the problem through the first two steps, everyone checks the name of the network service by themselves, OK directly enters the topic

Restart the network through the command line

If you are using Ubuntu Server, then you are already using the command line terminal. If you are using the desktop version, then you can open the command line terminal through the shortcut key Ctrl+Alt+T Ubuntu keyboard shortcut.

In Ubuntu, there are several commands to restart the network. Some or most of these commands also apply to restarting the network in Debian or other Linux distributions.

1. Network manager service

This is the easiest way to restart the network via the command line. It is equivalent to restarting the network through the graphical interface (restarting the Network-Manager service).

Solution steps

step one:

sudo vim /etc/NetworkManager/NetworkManager.conf

Change managed = false in the conf file to managed = true

Step 2: Restart the network-manager service:

sudo service network-manager restart

For different Linux systems, the network service name is different, mine is the following successful solution

sudo service NetworkManager restart

At this point, the network icon disappears for a moment and then reappears.

If solution 1 doesn’t work, try solution 2 again, it’s easy to use in personal test;
solution 2

Open a terminal and run the command:

sudo service network-manager stop

sudo gedit /var/lib/NetworkManager/NetworkManager.state

To change the contents of an open file:

Change NetworkingEnabled=false to NetworkingEnabled=true

After saving and exiting, run the command in the terminal:

sudo service network-manager start
或者
sudo service NetworkManager start

The result (the landlord is the second command)

Well, the network icon appears in the upper right corner, and there is a network~

2、systemd

The service command is just an encapsulation of this method (the same is the encapsulation of init.d series scripts and Upstart related commands). The systemctl command does much more than the service command. Usually I prefer to use this command. Because the landlord directly turned to the Internet!

sudo systemctl restart NetworkManager.service

At this time, the network icon will disappear for a while. If you want to know other options of systemctl, you can refer to the man help documentation.

3、nmcli

This is another tool for managing networks on Linux. This is a powerful and useful tool. Many system administrators like to use this tool because it is very easy to use.

This method has two steps: turn off the network, and then turn on the network.

sudo nmcli networking off

This will turn off the network and the network icon will disappear. Next, turn on the network again:

sudo nmcli networking on

You can learn more about the usage of nmcli through the man help documentation.

4、ifup & ifdown

These two commands directly operate the network port, and switch whether the network port can send and receive packets. This is one of the most should-know networking commands in Linux.

Use ifdown to close all network ports, and then use ifup to re-enable the network ports.

It is generally recommended to use these two commands together.

sudo ifdown -a && sudo ifup -a

Note: This method will not make the network icon disappear from the system tray, and in addition, various network connections will be broken.

Supplementary tool: nmtui Please check this on Baidu, after all, it is not used by professional operation and maintenance

The third type:

VMware virtual machine Ubuntu system does not have an IP address solution:
UPBROADCASTMULTICAST problem
VMware virtual machine
does not have a solution to net_addr address
Ifconfig
has been used for a long time, the virtual machine will be unable to connect to the Internet for no reason
In the terminal, use
the command to view the IP of the Ubuntu system address and found that no IP address was assigned.
ifconfig
eth0: network interface
link encap: network type
HWaddr: network card physical address
Inet addr: (internet address) IP address
Bcast: broadcast address
Mask: subnet mask
UP: network interface in use
RX packets,TX packets: the number of received and transmitted data packets
RX byte, TX byte: indicates the specific number of received and transmitted
Interrupt: terminal information
Base address: memory address
There are many Ubuntu systems in my VMware virtual machine software virtual machines, and they are used for a period of time, there will be no IP address problem. I always
thought it was a common problem of Ubuntu. However, I was wrong, it might not be an issue with Ubuntu, it might be an issue with my host machine. It turns out: my idea was correct.
I suddenly thought: I used anti-virus software to optimize the startup items before, and I turned off some VMware software related startup items. now i remember
Here:
Solution
Open the desktop, right-click "Computer", select "Management", select "Services and Applications", select "Services", and scroll down to: VMware.....: OK Now, it's done
.
Set the network of the Ubuntu virtual machine to NAT, and the Ubuntu virtual machine can go online. (Set it to NAT, as long as the host can access the Internet, the virtual machine can also access the Internet.)
Set the network of the Ubuntu virtual machine to automatic bridging, and the Ubuntu virtual machine can also get an IP address. (It is the IP address in the same LAN as the host.)

Guess you like

Origin blog.csdn.net/github_35856054/article/details/129685877