---- Linux Learning System Network Configuration

   Preface: If a computer wants to access the Internet, you must configure the IP address, subnet mask, gateway, DNS servers. In the Linux system, this information can be modified configuration file corresponding to the configuration. Temporary configuration about the network can use some simple commands to configure. For example ifconfig command.

1.1 ifconfig Command

  ifconfig is basic commands in GNU / Linux network card configuration, included in the net-tools package. The main role is a set configuration card, such as IP address, subnet mask, the maximum packet transmission tree, I / O ports. You can also enable or disable the network card.

  Ifconfig input terminal at the shell:

 

  In view of the results shown above, the host has two interfaces ens33, lo. Where, lo represents the host itself, also known as the loopback interface, its IP address convention is 127.0.0.1. The physical address of the representative of the host ens3 Ethernet card, network card is: 00: 0c: 29: 4d: f2: 1a, also known as MAC address; IP address: 192.168.19.128; broadcast address: 192.168.19.255; subnet mask code: 255.255.255.0.

  Format: NIC configuration temporary IP address:

    ifconfig NIC ip

  For example: configure the network card IP address: 192.168.198.133. Input may be provided on the shell: ifconfig ens33 192.168.198.133.

  

 

   Format: The physical address of the network card configuration:

     ifconfig  网卡  hw ether xx : xx : xx : xx : xx : xx

  For example: Configure NIC physical address 00: 11: 22: 33: 44: 55, the terminal can be entered in the shell.

    ifconfig ens33 hw ether  00:11:22:33:44:55

  Note: When the card is not disabled when not modify the physical address of the network card, network card device must be disabled before modifying.

  The network card device is disabled and open the command:

    sudo ifconfig ens33 down (closed NIC)

    sudo ifconfig ens33 up (open card)

  Modify the host network card physical address:

  

 

 

1.2 modify the configuration file to configure the IP address, gateway, subnet mask.

  For permanent configuration information, the configuration file must be modified. Whether a static IP or dynamic IP. Ubuntu system will be configured exist "/ etc / network / interfaces" information. IP address configuration information can be obtained at the Ubuntu system startup.

  If the static IP address configuration, the configuration file is read from the IP address parameter, directly configure a network interface device; if configured dynamic IP address, notifies the host acquires the network configuration through DHCP.

  The configuration process should pay attention to two points: 1. Open the / etc / network / interfaces file must be in a super administrator, otherwise can not be saved, 2 static configuration time, IP address, subnet mask and gateway should refer to the host location the actual network environment.

 (1) Dynamic Configuration

  sudo vi /etc/network/interfaces

  

 

   (2) static configuration

  sudo vi /etc/network/interfaces

  

 

   (3) to validate the configuration

    Just after modifying the configuration file, configuration parameters and there is no time to take effect, you need to manually enter "sudo /etc/init.d/network restart" command to validate the configuration on the terminal.

  While configured such information, but it only shows that the host has been connected to the LAN, that and the other hosts on the network can communicate directly with the local area. To be the same as browsing the Web browser does not work, because it is the domain name instead of IP addresses we normally entered on the browser. The domain name to be resolved by the DNS server. Only properly configured DNS server to function properly browse the Internet.

 

    

  

   

Guess you like

Origin www.cnblogs.com/eokey/p/11747155.html