Network Information view
Set Network address:
Cat /etc/sysconfig/Network-scripts/ifcfg-eth0
You will see:
DEVICE=Eth0
Bootproto=Statics
HWADDR=00: 0c:29:13:d1:6f
Onboot=yes
Type=ethernet
Ipaddr=192.168. 0.212
Netmask= 255.255. 255.0
Bootproto=statics: Indicates the use of the static IP address.
Onboot=Yes: Indicates that the NIC is started when it is powered on.
Take the dynamic IP address address
DEVICE=eth0
Onboot=Yes
Bootproto=dhcp
Set the IP address, it is not effective now oh, to restart the network card can be.
Ifconfig < network interface names > Networks < subnet masks >
Example: # ifconfig eth0 192.168.1.222 netmask 255.255.255.0
Note: Manually configuring the Linux network is limited to temporary use and configuration is not saved.
Extension: # ifconfig eth0:1 10.0.0.1 netmask 255.0.0.0 a network card configured with multiple child IP addresses.
# ifconfig eth0 hw ether MAC address modifies the MAC address of the NIC,
# /etc/rc.d/init.d/network start Start Network
#/etc/rc.d/init.d/network Stop Stop Network
#/etc/rc.d/init.d/network Restart Restart network
Host name configuration file, modifying host name
/etc/sysconfig/network
Example: # Vi/etc/sysconfig/network Use the VI Editor to open the hostname profile.
# Vi/etc/sysconfig/network
Networking=yes whether the network is available.
Hostname=xxxx xxxx is the host name for the new setting.
Local Host name resolution file
/etc/hosts
Hosts and DNS have similar host name resolution capabilities
Domain Name server configuration file
/etc/resolv.conf
You can set up to 3 lines with the previous entry into effect
viewing network interface Information
1. Understanding network interface Devices in Linux
$/sbin/ifconfig View all active network interface information, including an LO loopback port.
2. View information for a specified network interface
$/sbin/ifconfig < network interface name > view specified interface information.
3. View information for all network interfaces in the system
$/sbin/ifconfig–a View all interface information, including the inactive interface.
Note: When a normal user views the network interface information, it needs to add "/sbin" before the command, while the administrator does not. This is because of the command search path, which can be viewed through the $echo $PATH.
View gateway address and routing information
1. View Host Routing information
#/route
Displays the routing table information in the current Linux host.
#/route |grep Default
Lines starting with "default" in the display of the route command display the default gateway address for the host, combining the route command with the grep command, and displaying the default gateway address using the Filter route command.
2. Testing network links with other hosts
$ping Destination Host Address
Use the ping command to test network links to other hosts. CTRL + C terminates.
$ping –c < Test packet count > < destination host address >
Use the ping command to send a specified number of packets for network link testing.
The technique of using the ping command for network link testing.
Note: When the ping command is unsuccessful, it is not possible to determine that the current host is disconnected from the target host because there are many factors, such as a network firewall, that can cause the network connection to be non-pinging between hosts.
3, test and other host network link path
$traceroute < destination host address >
The traceroute command displays the address of the network node that is passing between the current host and the destination host, and the connection state of the current host to each intermediate node.
View Host name information
1. View the current host name
$Hostname View the current host name.
2. Use DNS server to query domain name
$Nslookup
Interactive mode: Typically used to test a DNS server
Direct mode: Used to query the corresponding IP address of a domain name
Using Network commands for Network setup
How to set up your network
1. DHCP Network configuration
$Dhclient Use the Dhclient command to request a new network configuration from the DHCP server to apply to the current host.
Note: DHCP servers typically provide the most basic network configuration information for DHCP clients, including: interface IP address, default gateway, DNS
The server address.
2. Manual Network Configuration
Network interface IP address and subnet mask
Default gateway Address
Current host name
DNS server address
IP address configuration commands
Ifconfig < network interface names > Networks < subnet masks >
Example: # ifconfig eth0 192.168.1.222 netmask 255.255.255.0
Note: Manually configuring the Linux network is limited to temporary use and configuration is not saved.
Extension: # ifconfig eth0:1 10.0.0.1 netmask 255.0.0.0 a network card configured with multiple child IP addresses.
# ifconfig eth0 hw ether MAC address modifies the MAC address of the NIC,
Routing configuration Commands
1. Remove the default gateway route
$Route del default GW < defaults gateway address >
2. Add default gateway route
$Route Add default GW < defaults gateway address >
Example: #route add default GW 192.168.1.1
Host name Configuration command
# hostname 123
Change the host temporary name to 123.
DNS Domain name resolution
Nslookup
>server
Displays the DNS server addresses used in the Linux system, and can also be temporarily set to take effect.
Modify the configuration file for network settings
Using Tools for Network setup
# Netconfig Graphical interface set up the network, after restarting the net takes effect.
What to fill in the interface:
The IP address of the host network interface.
The subnet mask for the network interface.
The default gateway address.
The IP address of the primary DNS server.
Network Service startup scripts
/etc/init.d/network to be effective from new start
Extension: #/etc/rc.d/init.d/network start Start Network
#/etc/rc.d/init.d/network Stop Stop Network
#/etc/rc.d/init.d/network Restart Restart network
Network Interface configuration file
/etc/sysconfig/network-scripts/ifconfg-*
Device=eth0 Network card number
Onboot=yes whether to start the network card when booting.
bootproto=static static IP or DHCP dynamic acquisition.
ipaddr=192.168.1.163 IP
netmask=255.255.255.0 Mask
gateway=192.168.1.1 Gateway
The following are the dynamic acquisition methods:
Device=eth0
Onboot=yes
Bootproto=dhcp
Stop and start the specified network interface
Once the configuration of a single network interface has been modified
Ifdown network Interface name stops a network interface.
Ifup the network interface name to open a network interface.
Note: Once the configuration files for a single network interface have been modified, you do not have to make the configuration file effective every time you start the networking service with the above command.
Extension: operation on network interface:
# ifconfig eth0 down Stop eth0 interface
# ifconfig eth0 up Open Eth0 interface
can be used continuously
Ifdown eth0; Ifup eth0
Host name configuration file
/etc/sysconfig/network
Example: # Vi/etc/sysconfig/network Use the VI Editor to open the hostname profile.
Networking=yes whether the network is available.
Hostname=xxxx xxxx is the host name for the new setting.
Local Host name resolution file
/etc/hosts
Hosts and DNS have similar host name resolution capabilities
Domain Name server configuration file
/etc/resolv.conf
You can set up to 3 lines before the entry takes effect.
Introduction to Basic Network configuration method of Linux network