, The significance of networks
Today, the Internet has become the most important in the development of human resources, have not sufficiently prepared to greet the coming of the Internet age, it has become in our lives and all closely related action of content. We have been unable to leave the network, just like life without eating. Although there are no people in the network era has existed for thousands of years, creating all sorts of great civilizations and brilliant achievements, but human desire and wisdom always to stay together, desire once the wisdom has been turned on, will become uncontrollable, unable to go back.
With the development and expansion of the network. The Internet company to network security and reliability requirements are also growing. We must be familiar with network management has become a fundamental skill.
Second, Centos 6 network management (Ethernet)
CentOS 6 network interfaces are named: ETH[0,1,2],CentOS 6 named based on the MAC address of the network interface to identify, first identify the network adapter named eth0, the second identified as eth1, and so on. This situation can lead to when you configured on eth0 network configuration file. When eth0 network card is broken. We bought a new NIC is back in the slot, but the network card name has been changed to eth1. This will cause the previous network configuration files cannot be used. This on a CentOS 7 has improved, this chapter we do shows.
Ifconfig command (to take effect immediately, but restart after system failure)
ifconfig [interface]
# ifconfig -a
[root@localhost ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:78:CB:FC
inet addr:192.168.0.114 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe78:cbfc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:189 errors:0 dropped:0 overruns:0 frame:0
TX packets:308 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20800 (20.3 KiB) TX bytes:53808 (52.5 KiB)
Base address:0xd010 Memory:f0000000-f0020000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
# Displays all network adapter information
# ifconfig IFACE [up|down]
# Disable or enable specified network card eth0
[root@localhost ~]# ifconfig eth0 down
[root@localhost ~]# ifconfig eth0 up
ifconfig interface [aftype] options | address …
# ifconfig IFACE IP/mask [up]
# Configure IP address for eth0, directly behind the specified mask bits
[root@localhost ~]# ifconfig eth0 192.168.1.1/24
# ifconfig IFACE IP netmask MASK
# Configure IP address for eth0, enter netmask+ directly behind the mask
[root@localhost ~]# ifconfig eth0 192.168.1.1 netmask 255.255.255.0
Route command (command routing management)
Views:
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
Add: route add
route add [-net|-host] target [netmask Nm] [gw Gw] [[dev] If]
# Specifies the target host to the 192.168.0.88 gateway is 192.168.0.1, forwarded via eth0 network card
[root@localhost ~]# route add -host 192.168.0.88 gw 192.168.0.1 dev eth0
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.88 192.168.0.1 255.255.255.255 UGH 0 0 0 eth0
Flags for the route sign marks the current state of the network nodes:
U Up says this route is currently as the start state
H Host, indicates that the gateway for a host
G–Gateway, this gateway as a router
R Reinstate Route, use dynamic routing to initialize routing
D Dynamically, this routing is dynamic to write
M is Modified, this routing is the routing daemon or dynamic modification Guide
! This route is currently closed
# Specifies the destination to the 192.168.0.0 network gateway is 192.168.0.1, forwarded via eth0 network card
[root@localhost ~]# route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0
[root@localhost ~]# route add -net 192.168.0.0/24 gw 192.168.0.1 dev eth0
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 192.168.0.1 255.255.255.0 UG 0 0 0 eth0
# Specify a gateway of 192.168.0.1 the default route, default route only need to add one, add more subject to article
[root@localhost ~]# route add -net 0.0.0.0/32 gw 192.168.0.1
[root@localhost ~]# route add default gw 192.168.0.1
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
Delete: route del
route del [-net|-host] target [gw Gw] [netmask Nm] [[dev] If]
# Remove a host route
[root@localhost ~]# route del -host 192.168.0.88
# Remove network routing
[root@localhost ~]# route del -net 192.168.0.0 netmask 255.255.255.0
# Remove default routes
[root@localhost ~]# route del default
Specifies the DNS server:
Edit:/etc/resolv.conf
nameserver DNS_SERVER_IP1(nameserver 8.8.8.8)
nameserver DNS_SERVER_IP2
nameserver DNS_SERVER_IP3
FQDN: (Fully Qualified Domain Name) full name of the fully qualified domain name/domain names, refers to host name together withthe full path, full paths are listed in the sequence for all domain members. All domain names can be logically and accurately showwhere the host can also say a complete representation of the domain name is the host name. Contains information that can be seenfrom the domain name domain name in host location in the tree. DNS resolution process: first look for native HOSTS table, somedefined directly using the table, set the DNS server does not find the network connection by him to resolve.
Truth: FQDN–>IP (www.Google.com–>216.58.221.36)
# dig -t A FQDN
[root@localhost ~]# dig -t A www.google.com
; <<>> DiG 9.3.4-P1 <<>> -t A www.google.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38677
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4
;; QUESTION SECTION (here is our problem in question):
;www.google.com. IN A
;; ANSWER SECTION (here is our answer to our question):
www.google.com. 370 IN A 216.58.221.36
;; AUTHORITY SECTION:
google.com. 11188 IN NS ns2.google.com.
google.com. 11188 IN NS ns1.google.com.
google.com. 11188 IN NS ns4.google.com.
google.com. 11188 IN NS ns3.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 30626 IN A 216.239.32.10
ns2.google.com. 12121 IN A 216.239.34.10
ns3.google.com. 21582 IN A 216.239.36.10
ns4.google.com. 10738 IN A 216.239.38.10
;; Query time: 12 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)(这里是我们指定为我们做解析的的DNS服务器)
;; WHEN: Thu Sep 3 17:27:02 2015
;; MSG SIZE rcvd: 184
# host -t A FQDN
[root@localhost ~]# host -t A www.google.com
www.google.com has address 216.58.221.36
反解:IP–>FQDN(216.58.221.36–>www.google.com)
# dig -x IP
[root@localhost ~]# dig -x 216.58.221.36
; <<>> DiG 9.3.4-P1 <<>> -x 216.58.221.36
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46451
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 4
;; QUESTION SECTION:
;36.221.58.216.in-addr.arpa. IN PTR
;; ANSWER SECTION:
36.221.58.216.in-addr.arpa. 281 IN PTR hkg08s13-in-f4.1e100.net.
36.221.58.216.in-addr.arpa. 281 IN PTR hkg08s13-in-f36.1e100.net.
;; AUTHORITY SECTION:
221.58.216.in-addr.arpa. 38624 IN NS ns1.google.com.
221.58.216.in-addr.arpa. 38624 IN NS ns3.google.com.
221.58.216.in-addr.arpa. 38624 IN NS ns2.google.com.
221.58.216.in-addr.arpa. 38624 IN NS ns4.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 30015 IN A 216.239.32.10
ns2.google.com. 11510 IN A 216.239.34.10
ns3.google.com. 20971 IN A 216.239.36.10
ns4.google.com. 10127 IN A 216.239.38.10
;; Query time: 13 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Sep 3 17:37:14 2015
;; MSG SIZE rcvd: 258
# host -t PTR IP
[root@localhost ~]# host -t PTR 216.58.221.36
36.221.58.216.in-addr.arpa domain name pointer hkg08s13-in-f36.1e100.net.
36.221.58.216.in-addr.arpa domain name pointer hkg08s13-in-f4.1e100.net
netstat命令:
netstat – Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
Displays the network connection:
netstat [–tcp|-t] [–udp|-u] [–raw|-w] [–listening|-l] [–all|-a] [–numeric|-n] [–extend|-e[–extend|-e]] [–program|-p]
-T:TCP agreement
-U:UDP agreement
-W:raw socket
-L: in the listening state
-A: all
-N: display IP and port with a number;
-E: extended formatting
-P: show related processes and PID
Common combinations:
-tan, -uan, -tnl, -unl
# Displays the State of all connections for a TCP protocol–related information, the digital display IP and port
[root@localhost ~]# netstat -tan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:833 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:6010 :::* LISTEN
tcp 0 0 ::ffff:192.168.0.114:22 ::ffff:192.168.0.107:62362 ESTABLISHED
# Display all connections for TCP protocol–related status information of the related processes and PID in digital display IP and port
[root@localhost ~]# netstat -tanp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:833 0.0.0.0:* LISTEN 1923/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1894/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2182/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2206/sendmail: acce
tcp 0 0 127.0.0.1:6010
Leave a Reply