Ubuntu10.10 Network Configuration
For a while, I was really confused about the network configuration of Ubuntu. I tried to find it on the Internet. I was a little careful.
Let's talk about the general configuration process first, and then go into some details.
I. configuration is divided into three categories: configuration through the configuration file, command configuration, and graphical network connection menu configuration.
Unlimited labs such as dial-up wireless are not involved.
Main file:/etc/network/interfaces. Here are some configurations of IP address, gateway, mask, etc;/etc/resolv. conf this file stores DNS information
Main Command: restart the network with sudo/etc/init. d/networking restart to invalidate the configuration file; add default gw in sudo route <IP address> to set the gateway.
Ii. configuration method
1. Configure through commands
If you only want to temporarily modify the IP address, you can choose this method. After the network is restarted, it will be lost.
1) sudo ifconfig eth0 <IP address> netmask <subnet mask> up
Eth0 is the network card. The last "up" indicates that the NIC is enabled and can be left empty.
2) sudo route add default gw <gateway IP address>
Set Gateway
3) set DNS, which must be modified in the configuration file.
4) configure the Host Name
Command: sudo/bin/hostname <Host Name>
However, when the system starts, the host name is read from/etc/hostname.
2. Configure through the configuration file
1) configure the IP Gateway: add it to sudo gedit/etc/network/interfaces
Dhcp:
Auto lo
Iface lo inet loopback
Auto eth0
Iface eth0 inet dhcp
Static IP:
Auto lo
Iface lo inet loopback
# The above is the loop
# Nic eth0 Configuration
Auto eth0
# Staic static IP
Iface eth0 inet static
Address 192.168.1.5
Netmask 255.255.255.0
Gateway 192.168.1.1
# Network 192.168.3.0
# Broadcast 192.168.3.255
# The following two are the network number and broadcast number, which can be calculated by other information, so you do not need to set
The second IP address (virtual IP address) can also be configured here)
Auto eth0: 1
Iface eth0: 1 inet static
Address 192.168.1.60
Netmask 255.255.255.0
# Network x. x
# Broadcast x. x
Gateway x. x
2) Configure DNS: sudo gedit/etc/resolv. conf
Nameserver 202.107.117.11
3) Host Name: Enter the host name in sudo gedit/etc/hostname. By default, a host name is provided, so this is not required.
4) restart the network: sudo/etc/init. d/networking restart
You can also restart the NIC:
Sudo ifconfig eth0 down
Sudo ifconfig eth0 up
Restarting the NIC does not affect other NICs. We recommend that you restart the NIC.
3. graphical network connection menu Configuration
This is also called network manager in system-preferences. You can use the network management Applet in the upper right corner to enable its configuration.
This is a problem: it shares the configuration file with the second method, which may lead to various conflicts.
As a result, both methods are configured, sudo/etc/init. d/networking restart enables the second method of configuration, and click auto eth0 in the network management applet on the desktop panel to enable the third method.