Ubuntu 10.10 configure the network

  • 2020-05-07 20:46:29
  • OfStack

For a while, I was really confused about the network configuration of Ubuntu, so I took the time to search the Internet carefully.
First say the general configuration process, and then go into some details.
1. There are roughly three types of configuration: configuration through a configuration file, configuration through a command, configuration through a graphical network connection menu.
main file: /etc/network/interfaces, here are some configuration of IP, gateway, mask, etc. /etc/ resolv.conf this file holds information about DNS
Main command: sudo/etc/init d/networking restart restart network, disable configuration file configuration; sudo route add default gw < IP address > , set the gateway.
2. Configuration method
1, configure by command
If you only want to temporarily modify the IP address, you can choose this method. It will be lost when the network is restarted.
1) sudo ifconfig eth0 < IP address > netmask < Subnet mask > up
eth0 is a network card. The last up indicates that the network card is enabled, which can be left unadded.
2) sudo route add default gw < The gateway IP >
Set the gateway
3) set DNS, which must be modified by the configuration file, just like the second one
4) configure the host name
Command: sudo /bin/hostname < The host name >
But when the system starts, the name of the host is read from /etc/hostname.

2, through the configuration file configuration
1) configure IP gateway: sudo gedit /etc/network/interfaces added
dhcp:
 


auto lo

iface lo inet loopback

auto eth0

iface eth0 inet dhcp

Static IP:

auto lo
iface lo inet loopback 
# The top one is the loop  
# The network card eth0 The configuration of the  
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 next two are the network number and the broadcast number, which can be calculated from other information, so there is no need to set 

You can also configure 2IP (virtual IP)

auto eth0:1 
iface eth0:1 inet static 
address 192.168.1.60
netmask 255.255.255.0
#network x.x.x.x 
#broadcast x.x.x.x
gateway x.x.x.x

2) configure DNS: sudo gedit /etc/ resolv.conf

nameserver 202.107.117.11

3) hostname: sudo gedit /etc/hostname There is a hostname by default, so this is not required.
4) restart the network: sudo/etc/init d/networking restart
You can also restart the network card:
sudo ifconfig eth0 down
sudo ifconfig eth0 up
Restart the network card to other network CARDS have no impact, more recommended 1.
3, through the graphical network connection menu configuration
This configuration is enabled in system-preferences, also known as network manager, through the network management applet in the upper right panel.
This is a bit of a problem: it shares configuration files with the second method, so it can cause all kinds of conflicts. Be careful when using it.
Than, both methods to do the configuration, sudo/etc/init d/networking restart enabled is 2 kinds of methods of configuration, and click on the desktop panel network management in the small program auto eth0 enabled is 3 kinds of configuration.


Related articles: