Configure the Network
Ifconfig command, you can view the IP address in Linux. Windows can be viewed in the command line with the ipconfig command.
After executing the ifconfig command, the information of the NIC is displayed and the Lo,lo is the test of whether the internal address of the machine is normal (from this computer to the network card connection)
The network card configuration file is stored in the/etc/sysconfig/network-scripts/ifcfg-eth0 file
To open the network adapter profile using the Vim/etc/sysconfig/network-scripts/ifcfg-eth0 command
Device= "eth0" Device name
Bootproto=static set whether the IP address is automatically assigned (DHCP) or manually assigned (static)
Nm_controlled= "Yes" (NetworkManager) graphical management is allowed, yes means allow
onboot= "Yes" if the device is enabled, yes indicates enabled
Type= "Ethernet" indicates the type of network card (currently Ethernet card)
ipaddr=192.168.0.124 IP Address
netmask=255.255.255.0 Subnet Mask
gateway=192.168.0.254 Gateway
dns1=192.168.0.254 Preferred DNS server (domain name resolution converts the domain name to an IP address)
PREFIX=24 Subnet Mask length
HWADDR=00:0C:29:AA:6F:CE Hardware address (MAC address)
Name= "System eth0"
last_connect=1410488442 Last Connection time
To configure IPv4, these 8 lines of code are required:
Device= "Eht0"
Bootproto=static
onboot= "Yes"
Type= "Ethernet"
ipaddr=192.168.0.150
netmask=255.255.255.0
gatway=192.168.0.254
dns1=192.168.0.254 (not necessarily)
Automatically assign IP:
Device= "Eht0"
Bootproto=dhcp
onboot= "Yes"
Type= "Ethernet"
After the configuration is complete, you need to restart the Network service with the service Network Restart command to take effect.
Configure sub-interfaces (to accommodate different network segments while surfing the Internet)
cd/etc/sysconfig/network-scripts/
CP Ifcfg-eth0 ifcfg-eth0:0
Copy and paste the original network configuration file, named ifcfg-eth0:0
vim/etc/sysconfig/network-scripts/ifcfg-eth0:0
Open the ifcfg-eth0:0 and change the parameters:
Device= "eth0:0"
Bootproto=static
onboot= "Yes"
Type= "Ethernet"
Ipaddr=192.168.1.123
netmask=255.255.255.0
gateway=192.168.0.254
dns1=192.168.0.254
Save exit, then use the command service NetworkManager stop, and then use the Service Network Restart command to restart the Network service to implement the sub-interface configuration, which can be viewed with the ifconfig command.
This article is from the "Raffaele" blog, make sure to keep this source http://raffaele.blog.51cto.com/6508076/1551759
Linux Learning Note 3