Under Linux NIC naming rules: eth0, eth1. First Ethernet card, and the second block. lo is the loopback interface, its fixed IP address is 127.0.0.1, mask 8. It represents your machine itself.
Ifconfig is the view card information
The interface is optional, and if not this information is displayed for all network cards in the system. If you add this option to display the specified card information.
eth0 Link encap: Ethernet HWaddr 00:0 C: 29: F3: 3B: F2 inet addr: 192.168.0.10
Bcast: 192.168.0.255 Mask: 255.255.255.0 UP BROADCAST RUNNING MULTICAST
MTU: 1500 Metric: 1 RX packets: 78 errors: 0 dropped: 0 overruns: 0
frame: 0 TX packets: 104 errors: 0 dropped: 0 overruns: 0 carrier: 0
collisions: 0 txqueuelen: 100 RX bytes: 11679 (11.4 Kb)
TX bytes: 14077 (13.7 Kb) Interrupt: 10 Base address: 0x1080 you can see:
First line: Connection Type: Ethernet (Ethernet) HWaddr (hardware mac address)
Second row: NIC IP address, subnet mask
The third line: UP (on behalf of the NIC turned on) Running (on behalf of the network adapter cable is connected) MULTICAST (support multicast) MTU: 1500 (Maximum Transmission Unit): 1500 bytes
Fourth, the five elements: receive, send the packet statistics
Seventh row: receiving, sending a number of data bytes statistical information.
(1) to configure the IP address of eth0 to activate the device at the same time.
# Ifconfig eth0 192.168.1.1 0 netmask 255.255.255.0 up
(2) Configuration the alias eth0 device eth0: 1 IP address, and add a route.
# Ifconfig eth0: 1 192.168.1.3
# Route add-host 192.168.1.3 dev eth0: 1
(3) to activate the device.
# Ifconfig eth0: 1 up
(4) to disable the device.
# Ifconfig eth0: down
(5) The view specified network interface configuration.
# Ifconfig eth0
(6) all network interface configuration.
2, the route command to configure and view the configuration of the kernel routing table
(1) Add a route to the host.
# Route add-host 192.168.1.2 dev eth0: 0
# Route add-host 10.20.30.148 gw 10.20.30.40
(2) added to the routing of the network.
# Route add-net 10.20.30.40 netmask 255.255.255.248 eth0
# Route add-net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
# Route add-net 192.168.1.0/24 eth1
(3) Add the default gateway.
# Route add default gw 192.168.1.1
(4) the configuration of the kernel routing table.
(5) Delete route.
# Route del-host 192.168.1.2 dev eth0: 0
# Route del-host 10.20.30.148 gw 10.20.30.40
# Route del-net 10.20.30.40 netmask 255.255.255.248 eth0
# Route del-net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
# Route del-net 192.168.1.0/24 eth1
# Route del default gw 192.168.1.1
For two points 1 and 2 can use the following statement:
Service network restart
Traceroute command packet to the destination host through routing
# Traceroute www.techsoftcenter.com
4, the ping command to test network connectivity
# Ping www.techsoftcenter.com
# Ping-c 4 192.168.1.12
5, the netstat command to display network status information
Main purpose: View the connection status of the network (only TCP, UDP invalid), check the interface configuration information, check the routing table, to obtain the system
Taking into account information. TCP, UDP port status display obtained without parameters, because UDP is a connectionless protocol, so the state of its meaningless. Common
State: ESTABLISHED, LISTENING, TIME-WAIT, respectively, in a connected state, waiting for a connection, close the connection.
Several parameters option, the user can be used to view the information on different aspects of the network, its parameters are described below:
-A: option to show all configured interface
-I: option to display interface statistics
-N: options for the IP address in digital form
-R: option displays the kernel routing table
-S: option means that the value of the counter.
(1) Display Network Interface Status.
(2) Show all monitoring server Socket and Socket program information.
(3) Show the kernel routing table information.
(4) shows the connection status of the
TCP / UDP transport protocol.
Hostname change the hostname
# Hostname myhost
7 arp command to configure and view the ARP cache
(1) View the ARP cache.
(2) Add an IP address and MAC address of the corresponding record.
# Arp-s 192.168.33.15 00:60:08:27: CE: B2
(3) Delete an IP address and MAC address of the corresponding cache records.
Ifup command is used to start the specified period of inactivity LAN equipment
This command is similar to the
ifconfig up command. Ifdown command is used to stop the specified activities LAN equipment, the command
ifconfig down command
Similar. The two command format is as follows:
the ifup NIC device name
the ifdown card device name
Nslookup queries the DNS database user-level commands
exit command: to exit nslookup command.
command of lserver: Find the specified domain name server and set it as the default domain name server.
server command: lserver of similar resolve another domain name server and set it as the default server, except that the command uses the current tacit
Put the server to resolve.
the set command: modify the operating parameters, it is also nslookup most commonly used commands, use the operating parameters of the operating parameters such as the nslookup procedures set command.
Operating parameters: set class set the query type, under normal circumstances, Internet.
Set debug mode/set nodebug: set to a non-debug mode
set d2 set debug mode. / Set nod2: set to a non-detailed debug mode.
set [no] defname the set defname will automatically add the default domain name after all did not add the name of the “o”. It is the default.
set domain to set the default domain name.
The SET PORT DNS the default port of 53, this command can set a different port, generally used for debugging.
Set the q (querytype), change the type of information. The default type A record
set recurse set the query type is recursive;
set retry set the number of retries. The default value is 4.
set root to set the default root server.
set timeout set to wait for the response time limit (in seconds), the excess is the time-out, if it can retry will double the long timeout value, re-
New Query. The default timeout value is 5 seconds.
10 tcpdump command is used to monitor TCP / IP connection and directly read the data link layer packet header information
The user can specify which data packets are monitored, which control the display format. For example, to monitor all communication between Ethernet, perform the following command
# Tcpdump-i eth0
In fact, the tcpdump command format:
for tcpdump [- options] [-c number] [-F file name] [-i network interface] [-r file
Name] [-s snaplen]
[-T type] [-w filename] [expression]
The tcpdump command option parameters xia shown. Tcpdump command expression is a regular expression, tcpdump use it as a filter reported
Conditions, if a packet satisfies the conditions of the expression, then the packet will be captured. If you did not give any conditions, all the letters in the network
Interest packet will be intercepted.
the tcpdump command Options Introduction: Parameters Field Description
-A network address and broadcast address into a name;
-D will match the code of the packet is given to the assembler format that people can understand;
-Dd will match the code of the packet is given to the format of the c language program segment;
-DDD will match the packet code is given in decimal form;
-E print out the data link layer header information in the output line;
-F the external Internet address printed out in the digital form;
-L Make stdout line buffered;
-N Do not network address into a name;
-T does not print a timestamp for each output line;
-V output slightly more detailed information, such as IP package can include TTL and service type information;
-Vv output of the detailed packet information;
-C received after the specified number of packets, tcpdump stops;
-F expression read from the specified file, ignoring other expressions;
-I specify the network interface of the listener;
-R read from the specified file package (package-w option);
– W direct packet writing the file, do not analyze and print out;
-T will listen to the packets directly explain specify the types of messages, a common type
RPC (remote procedure call) and SNMP (Simple Network Management Protocol 😉
11 network configuration files and procedures
1, network settings / etc / sysconfig / network file is used to specify the server on the network configuration information, including the control and network-related documents and guardian
Parameters for the behavior of the program.
/ Etc / rc.d / init.d / network restart
2, the mapping between the port number and server name / etc / services
3, the configuration name parser / etc / host.conf
4, configure the DNS client / etc / resolv.conf
5, using the netconfig program to configure the network