Ubuntu10.04 Network Configuration

Source: Internet
Author: User


To set the network, specify the IP address and DNS server. The configuration files in Ubuntu are as follows:
/Etc/Network/interfaces and/etc/resolv. conf files:
You can run the man command to view the format description of the two files:
WZB @ Ubuntu :~ $ Man Interfaces
WZB @ Ubuntu :~ $ Man resolv. conf

First, run the command ifconfig-a to view the system Nic. Generally, eth0 and lo are the first Nic of the Ethernet and the NIC used for local loop testing.
You can set eth0 as follows:
1. Configure the NIC in DHCP Mode
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Replace eth0 with the following rows:
# The primary network interface-use DHCP to find our address
Auto eth0
Iface eth0 Inet DHCP
Run the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
Of course, you can also enter the following command under the command line to obtain the address
Sudo dhclient eth0
2. configure a static IP address for the NIC
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Replace eth0 with the following rows:
# The primary network interface
Auto eth0
Iface eth0 Inet static
Address 192.168.3.90
Gateway 192.168.3.1
Netmask 255.255.255.0
Network 192.168.3.0
Broadcast 192.168.3.255
Replace the above IP address and other information with your own.
Run the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
3. Set the second IP address (virtual IP address)
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Add the following lines to the file:
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
Fill in all information such as address, netmask, network, broadcast, and gateway according to your situation.
Run the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
4. Set Host Name (hostname)
Run the following command to view the Host Name of the current host:
Sudo/bin/hostname
Run the following command to set the Host Name of the current host:
Sudo/bin/hostname newname
When the system starts, it reads the host name from/etc/hostname.
For more information about setting host names, run the man command to view more details about hostname:

(Note: This hostname is both a command and a file. Will man hostname get what we want? The answer is no,

Obtain the manual for the command hostname. You can obtain the hostname script file format as follows)

View plaincopy to clipboardprint?
View plaincopy to clipboardprint?
  1. WZB @ Ubuntu :~ $ Man hostname
  2. WZB @ Ubuntu :~ $ Whatis hostname
  3. Hostname (7)-hostname resolution description
  4. Hostname (1)-show or set the system's host name
  5. WZB @ Ubuntu :~ $ Whereis hostname
  6. Hostname:/bin/Hostname/etc/Hostname/usr/share/man/man7/hostname.7.gz/usr/share/man/Man1/hostname.1.gz
  7. WZB @ Ubuntu :~ $ Whereis-M hostname
  8. Hostname:/usr/share/man/man7/hostname.7.gz/usr/share/man/Man1/hostname.1.gz
  9. WZB @ Ubuntu :~ $ MAN 7 hostname



WZB @ Ubuntu :~ $ Man hostname
WZB @ Ubuntu :~ $ Whatis hostname
Hostname (7)-hostname resolution description
Hostname (1)-show or set the system's host name
WZB @ Ubuntu :~ $ Whereis hostname
Hostname:/bin/Hostname/etc/Hostname/usr/share/man/man7/hostname.7.gz/usr/share/man/Man1/hostname.1.gz
WZB @ Ubuntu :~ $ Whereis-M hostname
Hostname:/usr/share/man/man7/hostname.7.gz/usr/share/man/Man1/hostname.1.gz
WZB @ Ubuntu :~ $ MAN 7 hostname


 

5. Configure DNS
First, you can add some host names to/etc/hosts and the IP addresses corresponding to these host names. This is a simple static query on the local machine.
To access the DNS server for query, you need to set the/etc/resolv. conf file.
Assume that the IP address of the DNS server is 8.8.8.8, the content of the/etc/resolv. conf file should be:
Search Google.com
Nameserver 8.8.8.8
Okay, the file is basically configured: Use sudo/etc/init. d/networking start to make it take effect! (Sudo ifup-A is also effective in the/etc/Network/interfaces file)
Use ifconfig-a to check whether the address is specified in the/etc/Network/interfaces script file.
Finally, run the ping command to test your network: Ping www.baidu.com.


Http://blog.csdn.net/wzb56/archive/2011/02/14/6183122.aspx

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.