监控系统状态
-
w命令/uptime
load average: 0.00, 0.01, 0.05
上面这条显示的就是系统负载。后面有三段数字
[root@localhost ~]# w
21:33:04 up 41 min, 1 user, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.245.1 20:53 0.00s 0.10s 0.02s w
[root@localhost ~]#
第一个数值表示一分钟内系统的平均负载值,第二个数值表示5分钟内系统的平均负载值,第三个数值表示15分钟内系统的平均值。
主要着重看第一个值,值越大说明服务器的压力越大。一般情况下这个值只要不超过服务器的cpu数量就没有关系。
查看系统有几个cpu : cat /proc/cpuinfo
看processor的值是多少,0就表示有1个逻辑cpu。10就表示有11个逻辑cpu
[root@localhost ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
stepping : 4
microcode : 0x22
cpu MHz : 2294.250
cache size : 3072 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 20
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt
bogomips : 4589.38
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
[root@localhost ~]#
vmstat
当我们发现系统的负载偏高的时候,可以用vmstat来查看都有哪些原因导致配置不够用了。
[root@localhost ~]# vmstat
内存 虚拟内存 磁盘 系统进程
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 715284 892 169560 0 0 30 3 35 63 0 0 99 0 0
[root@localhost ~]#
一般用vmstat 1 来查看系统负载。这条命令的意思是每一秒钟进行动态显示
[root@localhost ~]# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 715440 892 169592 0 0 29 3 35 62 0 0 100 0 0
0 0 0 715424 892 169592 0 0 0 0 45 60 0 1 99 0 0
0 0 0 715424 892 169592 0 0 0 0 24 34 0 0 100 0 0
0 0 0 715424 892 169592 0 0 0 0 33 41 1 0 99 0 0
0 0 0 715424 892 169592 0 0 0 0 38 42 0 1 99 0 0
0 0 0 715424 892 169592 0 0 0 0 36 49 0 0 100 0 0
^C
[root@localhost ~]#
后面再加上一个数字就是指定显示几行后结束
[root@localhost ~]# vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 715440 892 169592 0 0 26 3 34 60 0 0 100 0 0
0 0 0 715424 892 169592 0 0 0 0 28 42 0 0 100 0 0
0 0 0 715424 892 169592 0 0 0 0 28 34 0 0 100 0 0
[root@localhost ~]#
其中r(run)的意思:表示运行或者等待的时间的进程数。因为某一个时刻只有一个进程在用一个cpu,如果有十个进程,就会一个进程在某一个时间运行,到时间了,就运行下一个进程。进行轮流运行,其他进程在排队。
b:(block) : 等待资源的进程数。比如进程在进行完成之后要写入磁盘,这时候如果硬盘的负载很高,读写速度慢,或者网速太慢了。导致进程出现等待的情况。
swpd :表示切换到交换分区中的内存数量,单位为KB。
free : 表示当前空闲的内存数量,单位为KB。
buff : 表示(即将写入磁盘的)缓冲大小,单位为KB。
cache : 表示(从硬盘中读取的)缓存大小,单位为KB。
si : 表示由交换区写入内存的数据量,单位为KB.
so : 表示由内存写入交换分区的数据量,单位为KB.
bi : 表示从块设备读取数据的量(读磁盘),单位为KB.
bo :写磁盘 ,单位为KB。
in : 表示某一时间间隔内观测到的每秒设备的中断次数。
cs : 表示每秒产生的上下文切换次数。
us : 显示用户下所花费CPU的资源的百分比。
sy :显示系统花费CPU的资源的百分比。
id : 表示cpu处于空闲状态的资源百分比。
wa : 表示I/O等待所占用CPU的时间百分比。
st : 表示被偷走的cpu所占百分比,(比如虚拟机会偷走物理机的cpu)一般都是0,不用关注。
top 查看进程使用资源情况
top - 22:47:23 up 1:55, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 94 total, 1 running, 93 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 999936 total, 714648 free, 114544 used, 170744 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 707696 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
543 root 20 0 302636 6168 4788 S 0.3 0.6 0:15.07 vmtoolsd
2108 root 20 0 143096 5152 3876 S 0.3 0.5 0:00.77 sshd
1 root 20 0 128092 6704 3952 S 0.0 0.7 0:01.91 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.27 ksoftirqd/0
6 root 20 0 0 0 0 S 0.0 0.0 0:00.34 kworker/u256:0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.56 rcu_sched
10 root rt 0 0 0 0 S 0.0 0.0 0:00.09 watchdog/0
12 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
26 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
27 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
28 root 39 19 0 0 0 S 0.0 0.0 0:00.06 khugepaged
29 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
30 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
38 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld
39 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u256:1
40 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kmpath_rdacd
41 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
43 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ipv6_addrconf
默认按照cpu百分比进行排列
数字单位是k字节。
按大写字母M是以内存排序
按大写P,是以cpu排序
按数字1,可以列出所有核cpu的使用情况。
按q退出。
top -bn1 :表示非动态打印系统资源的使用情况,可以用在shell脚本中。
sar命令
几乎可以监控系统的所有资源状态。俗称linux系统的瑞士军刀。
首先需要安装这个命令。
[root@localhost ~]# sar
-bash: sar: 未找到命令
[root@localhost ~]# yum install -y sysstat
sar -n DEV 1 3 每一秒显示三次
[root@localhost ~]# sar -n DEV 1 3
Linux 3.10.0-514.el7.x86_64 (localhost.localdomain) 2017年09月11日 _x86_64_ (1 CPU)
23时15分34秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
23时15分35秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
23时15分35秒 ens33 1.01 1.01 0.06 0.20 0.00 0.00 0.00
23时15分35秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
23时15分36秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
23时15分36秒 ens33 1.00 1.00 0.06 0.40 0.00 0.00 0.00
23时15分36秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
23时15分37秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
23时15分37秒 ens33 0.99 0.99 0.06 0.40 0.00 0.00 0.00
平均时间: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 1.00 1.00 0.06 0.33 0.00 0.00 0.00
[root@localhost ~]#
rxpck/s 表示每秒进入收取包的数量。txpck/s 表示每秒发送出去包的量。rxkb/s 表示每秒收取的量单位为kb,txkb/s表示每秒发送的数据量。
数据包几千是正常的,如果数据包上万或者几十万,就很有可能被攻击了。可以进行抓包查看。
sar -q 查看历史负载
sar -n DEV -f /var/log/sa/sa17 查看某一天的网卡流量历史,sa17每10分钟生成一次,二进制文件,不能直接cat
sar -n DEV -f /var/log/sa/sar17 sar17是每天生成一次,可以直接cat查看
sar -b 查看磁盘。
nload命令
首先需要安装yum install epel-release
然后安装yum install -y nload
非常直观的查看网卡,按方向键切换网卡,按q退出
Device ens33 [192.168.245.128] (1/2):
====================================================================================================================================================
Incoming:
Curr: 944.00 Bit/s
Avg: 1.26 kBit/s
Min: 944.00 Bit/s
Max: 2.76 kBit/s
Ttl: 6.86 MByte
Outgoing:
Curr: 9.05 kBit/s
Avg: 8.91 kBit/s
Min: 4.23 kBit/s
Max: 9.49 kBit/s
Ttl: 3.48 MByte
监控io性能
[root@localhost ~]# iostat
Linux 3.10.0-514.el7.x86_64 (localhost.localdomain) 2017年09月12日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.11 0.00 0.23 0.01 0.00 99.66
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 1.61 19.24 1.76 124103 11353
sdb 0.07 0.53 0.00 3407 4
scd0 0.00 0.01 0.00 44 0
dm-0 0.01 0.07 0.00 456 0
[root@localhost ~]#
-
iostat -x
[root@localhost ~]# iostat -x
Linux 3.10.0-514.el7.x86_64 (localhost.localdomain) 2017年09月12日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.10 0.00 0.23 0.01 0.00 99.66
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.02 1.11 0.42 18.29 1.68 26.04 0.00 0.37 0.34 0.44 0.27 0.04
sdb 0.00 0.00 0.07 0.00 0.50 0.00 14.30 0.00 0.09 0.09 1.00 0.08 0.00
scd0 0.00 0.00 0.00 0.00 0.01 0.00 8.00 0.00 0.45 0.45 0.00 0.45 0.00
dm-0 0.00 0.00 0.01 0.00 0.07 0.00 15.20 0.00 0.08 0.08 0.00 0.07 0.00
[root@localhost ~]#
着重看%util列,如果数值很大,说明读写很忙。如果读写不大,说明硬盘有问题。
-
iotop 来查看占用IO高的进程
没有安装过:yum install -y iotop
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
2434 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.03 % [kworker/0:2]
1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % systemd --switched-root --system --deserialize 21
2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]
3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0]
6 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u256:0]
7 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0]
8 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_bh]
9 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_sched]
10 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0]
12 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khelper]
13 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kdevtmpfs]
14 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [netns]
15 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khungtaskd]
16 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [writeback]
17 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kintegrityd]
18 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [bioset]
19 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kblockd]
20 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [md]
533 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % vmtoolsd
534 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % systemd-logind
26 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kswapd0]
27 be/5 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksmd]
28 be/7 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khugepaged]
29 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [fsnotify_mark]
30 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [crypto]
545 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % agetty --noclear tty1 linux
548 be/4 polkitd 0.00 B/s 0.00 B/s 0.00 % 0.00 % polkitd --no-debug [gmain]
38 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthrotld]
39 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u256:1]
40 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kmpath_rdacd]
41 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kpsmoused]
free命令
直接查看内存使用的命令
[root@localhost ~]# free
total used free shared buff/cache available
Mem: 999936 121540 581256 6844 297140 693540
Swap: 2097148 0 2097148
[root@localhost ~]#
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 976M 118M 567M 6.7M 290M 677M
Swap: 2.0G 0B 2.0G
[root@localhost ~]#
buff/cache缓冲/缓存,缓存,是cpu向硬盘读取数据的时候,缓存(cache)在内存里。缓冲是:cpu处理完的数据写入磁盘,缓冲(buff)在内存里面。
公式:total=used + free + buff/cache
avaliable包含free和buffer/cache剩余部分。
ps命令
-
ps aux
静态显示所有的进程
-
ps aux |grep nginx
查看某一个进程
[root@localhost ~]# ps aux |grep nginx
root 2757 0.0 0.0 112664 968 pts/0 R+ 20:57 0:00 grep --color=auto nginx
[root@localhost ~]#
PID :进程ID,用于杀掉一个进程,kill 2757
查看一个进程:ls -l /proc/505/
-
ps aux 后关注STAT列
D不能中断的进程
R run状态的进程
S sleep状态的进程
T 暂停的进程
Z 僵尸进程
< 高优先级进程
N 低优先级进程
L 内存中被锁了内存分页
s 主进程
l 多线程进程
+ 前台进程
-
ps -elf
和ps aux 差不多。
netstat 查看网络状态
-
netstat -lnp 查看监听端口
[root@localhost ~]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 887/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1494/master
tcp6 0 0 :::22 :::* LISTEN 887/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1494/master
udp 0 0 127.0.0.1:323 0.0.0.0:* 542/chronyd
udp6 0 0 ::1:323 :::* 542/chronyd
raw6 0 0 :::58 :::* 7 581/NetworkManager
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 12552 1/systemd /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 12561 1/systemd /run/lvm/lvmpolld.socket
unix 2 [ ACC ] STREAM LISTENING 19948 1494/master private/bounce
unix 2 [ ACC ] STREAM LISTENING 19951 1494/master private/defer
-
netstat -an
-
netstat -an | awk '/^tcp/ {++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'
[root@localhost ~]# netstat -an | awk '/^tcp/ {++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'
LISTEN 4
ESTABLISHED 1
主要看ESTABLISHED,这个数字大,说明系统忙。网站并发连接数,就是同一时刻有多少个客户端连着。
linux 下抓包
-
抓包工具tcpdump
没有这个命令需要安装一下:yum install -y tcpdump
指定网卡名字 tcpdump -nn -i ens33
运行完上面命令后会出现密密麻麻的一堆字符串,在按Ctrl+c 之前,这些字符串一直在刷屏,刷屏越快说明网卡上的数据包越多。我们只需要关注第3列和第4列,它们显示的信息为哪一个ip+端口号在连接哪一个ip+端口号。
-nn选项的作用是让第3列和第4列显示成"ip+端口号"的形式,如果不加-nn选项则显示“主机名+服务名称” -i 选项后面跟设备名称。
tcpdump -nn -i ens33 port 22 指定只抓22端口的包
tcpdump -nn -i ens33 tcp and not port 22 指定抓tcp的包,但是不要22端口的
tcpdump -nn -i ens33 port 22 and port 53 只抓22和53 端口的包。
tcpdump -nn -i ens33 -c 100 只抓100条
tcpdump -nn -i ens33 -c 100 -w /tmp/1.cap 抓100条然后保存到/tmp/1.cap
tcpdump -r /tmp/1.cap 查看这个抓取的数据包。
-
抓包工具 wireshark
yum install -y wireshark
tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e "http.request.method" -e "http.request.uri"
-
ifconfig 查看网卡及ip,子网,网关,mac地址
yum install net-tools
-
重启指定网卡 ifdown 网卡名字 && ifup 网卡名字
-
添加虚拟网卡
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functions
ifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnel
ifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wireless
ifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33\:0
[root@localhost network-scripts]# vi !$
vi ifcfg-ens33\:0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=c6ff01b6-78d5-462c-b288-7acfafa4f5b5
DEVICE=ens33:
ONBOOT=yes
IPADDR=192.168.245.130
NETMASK=255.255.255.0
~
[root@localhost network-scripts]# ifdown ens33 && ifup ens33
成功断开设备 'ens33'。
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/1)
[root@localhost network-scripts]#
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.245.128 netmask 255.255.255.0 broadcast 192.168.245.255
inet6 fe80::dbd:48aa:6994:bf39 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d6:6f:fa txqueuelen 1000 (Ethernet)
RX packets 4396 bytes 330121 (322.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1291 bytes 122535 (119.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.245.130 netmask 255.255.255.0 broadcast 192.168.245.255
ether 00:0c:29:d6:6f:fa txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 80 bytes 6940 (6.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 80 bytes 6940 (6.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
虚拟网卡能ping通
-
查看一个网卡的网线是否连接 mii-tool ens33
[root@localhost network-scripts]# mii-tool ens33
ens33: negotiated 1000baseT-FD flow-control, link ok
[root@localhost network-scripts]#
link ok 代表连接,no link 代表未连接
或者使用ethtool ens33也能查看。
-
更改计算机名
[root@localhost network-scripts]# hostnamectl set-hostname aminglinux-01
[root@localhost network-scripts]# hostname
aminglinux-01
[root@localhost network-scripts]# bash
[root@aminglinux-01 network-scripts]#
-
查看DNS
[root@aminglinux-01 network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 119.29.29.29
[root@aminglinux-01 network-scripts]#
扩展学习
tcp三次握手四次挥手(重点) http://www.doc88.com/p-9913773324388.html tshark几个用法:http://www.aminglinux.com/bbs/thread-995-1-1.html