The use of Ubuntu11.04 in the past few days has been very upset by network configuration problems.
This Ubuntu is installed in a notebook and has a static IP address in the dormitory. It is automatically obtained through wireless networks in the lab. At the beginning, the system was installed. If the wireless network is enabled, the system can access the Internet. So I thought Ubuntu's network configuration was quite good. Go back to the dormitory, configure the static IP address and DNS, open the webpage, and access the internet. Pretty good.
But the next day, the tragedy came. There is no problem with the lab wireless network. The problem is that after you return to the dormitory, you cannot access the Internet. Ping and unreachable. Check the IP settings. Therefore, when networking is restarted, You can ping it, but you still cannot access the Internet. Let's look at DNS again. Hmm? Empty? What if the dns set up yesterday is cleared? How can this happen? There is also a line of comment in the file, generated by network manager. Is it cleared when the wireless network gets it automatically? Or is it because the dns settings are cleared after the restart? So I tried it and restarted it. I couldn't access the internet. I checked the ip address and DNS and set it correctly. networking restarted and I was able to access the Internet. It seems that the dns configuration should be cleared when the wireless network automatically obtains the ip address. Alas, this ubuntu...
Let's simply talk about the network configuration. Although ubuntu has a network manager, it does not seem to work after the configuration, it is best to use file configuration. Step 2: set ip address and dns.
Step 1: Set the ip address.
Use the root permission to edit the file/etc/network/interfaces. There are two rows:
Auto lo
Iface lo inet loopback
These two rows are generally available and do not need to be changed. Next, configure the local network,
Auto eth0
Iface eth0 inet static
# These two statements indicate that eth0 uses static IP addresses ).
# If you need to change the mac address
Hwaddress ether xx: xx
# Ip address x. x
# Gateway x. x
# Netmask mask x. x
# Setting dns here seems useless
Dns-nameserver x. x
Step 2: Set dns to use root permission to edit/etc/resolv. conf,
# Add dns
Nameserver 202.120.2.101
Nameserver x. x
After setting, restart the network service. The root permission command is as follows:/etc/init. d/networking restart. You can access the Internet.
Other questions:
If you want to dynamically obtain the IP address, change static to dhcp, and the subsequent IP address does not need to be set. Dynamic IP address acquisition is generally not related to mac.
For wireless networks, change eth0 to wlan0. if there is a network problem, you can view the current network status through ifconfig, such as whether eth0 has an ipv4 address. If not, set it first and then restart the network service. If you have an address and ping results, but the browser cannot open the webpage, you may need to check the dns settings.