ifconfig

查看生效的ip信息。

[root@local ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255
inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet)
RX packets 7492 bytes 625846 (611.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3334 bytes 451391 (440.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 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 0 (Local Loopback)
RX packets 12 bytes 1020 (1020.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1020 (1020.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8c:58:59 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ifconfig 命令看不到网关和DNS。

ifdown,ifup

关闭和启动网卡

[root@local ~]# ifdown lo
[root@local ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255
inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet)
RX packets 7600 bytes 634935 (620.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3384 bytes 457849 (447.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8c:58:59 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@local ~]# ifup lo
[root@local ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255
inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet)
RX packets 7647 bytes 638881 (623.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3416 bytes 462387 (451.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 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 0 (Local Loopback)
RX packets 12 bytes 1020 (1020.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1020 (1020.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8c:58:59 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

netstat

查看网络状态

-t 列出tcp协议端口

-u 列出udp协议端口

-n 不使用域名与服务名,使用IP和端口

-l 列出监听状态的网络服务

-a 列出所有的网络连接

-r 路由信息

-p 列出pid,进程id

[root@local ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.70.70 0.0.0.0 UG 0 0 0 eno16777736
192.168.70.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16777736
[root@local ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.70.70 0.0.0.0 UG 100 0 0 eno16777736
192.168.70.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
[root@local ~]# netstat -anp|grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1185/sshd
tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED 2436/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1185/sshd
[root@local ~]# netstat -an|grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
[root@local ~]# netstat -tunl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 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
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 127.0.0.1:323 0.0.0.0:*
udp 0 0 0.0.0.0:46466 0.0.0.0:*
udp6 0 0 ::1:323 :::*

通过这条指令查看当前计算机开启了哪些服务。

[root@local ~]# netstat -an|grep ESTABLISHED
tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED

查看正在连接我的计算机。

[root@local ~]# netstat -an|grep ESTABLISHED |wc -l
1

通过两个管道可以统计出数量。

网关不可以乱设置,如果设置多个,或者设置的网关地址不存在,很可能就无法上网了。

nslookup

查看DNS

[root@local ~]# nslookup www.qq.com
Server: 114.114.114.114
Address: 114.114.114.114#53 Non-authoritative answer:
Name: www.qq.com
Address: 180.96.86.192 [root@local ~]# ping www.qq.com
PING www.qq.com (180.96.86.192) 56(84) bytes of data.
64 bytes from 180.96.86.192: icmp_seq=1 ttl=54 time=9.60 ms
64 bytes from 180.96.86.192: icmp_seq=2 ttl=54 time=9.33 ms

ping 命令

查看是否可以通信

[root@local ~]# ping -c 4 www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=55 time=9.04 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=55 time=10.2 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=55 time=9.07 ms
64 bytes from 180.97.33.107: icmp_seq=4 ttl=55 time=14.9 ms --- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 9.042/10.825/14.948/2.429 ms

telnet

远程管理,明文通信。数据包在互联网上不会被加密。建议少用。

traceroute

跟踪查看路由命令

[root@local ~]# traceroute www.baidu.com
traceroute to www.baidu.com (180.97.33.107), 30 hops max, 60 byte packets
1 192.168.70.70 (192.168.70.70) 0.275 ms 0.274 ms 0.223 ms
2 192.168.1.1 (192.168.1.1) 0.555 ms 0.604 ms 0.534 ms
3 100.73.0.1 (100.73.0.1) 3.010 ms 3.316 ms 3.267 ms
4 222.187.235.217 (222.187.235.217) 2.718 ms 2.646 ms 2.585 ms
5 222.187.235.105 (222.187.235.105) 13.826 ms 13.559 ms 13.826 ms
6 202.102.73.122 (202.102.73.122) 16.276 ms 202.102.73.126 (202.102.73.126) 19.856 ms 202.102.69.186 (202.102.69.186) 13.546 ms
7 * * *
8 180.97.32.130 (180.97.32.130) 13.049 ms 180.97.32.26 (180.97.32.26) 139.445 ms 180.97.32.2 (180.97.32.2) 10.769 ms
9 * * *
[root@local ~]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=55 time=9.25 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=55 time=9.55 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=55 time=9.30 ms

*** 表示ping不同的地址

wget

下载命令

tcpdump

抓包命令

[root@local 桌面]# tcpdump -i eth0 -nnX port 22

-i 指定监听的网卡

-nn 将数据包中的域名与服务转为ip和端口

-X 以16进制和ASCII码显示数据包内容

prot指定监听的端口

scp

远程上传或者下载

[root@localhost ~]# scp -r testscp/ root@192.168.70.77:/root
The authenticity of host '192.168.70.77 (192.168.70.77)' can't be established.
RSA key fingerprint is c1:d1:80:44:94:0b:e2:fb:b4:82:20:79:5f:94:5f:41.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.70.77' (RSA) to the list of known hosts.
root@192.168.70.77's password:
hello 100% 10 0.0KB/s 00:00

这个是上传。

[root@localhost testscp]# scp -r root@192.168.70.77:/root/testscp /root
root@192.168.70.77's password:
hello 100% 10 0.0KB/s 00:00
world 100% 12 0.0KB/s 00:00

这个是下载。

Linux - 常用网络命令详解netstat,scp的更多相关文章

  1. Linux常用文件管理命令详解

    cat cat命令用于连接文件并打印到标准输出设备上. 命令语法:cat [参数] [文件名] 参数说明: 参数 说明 -n 由1开始对所有输出的行数进行编号. -b 由1开始对所有输出的行数进行编号 ...

  2. Linux主要shell命令详解(上)

    [摘自网络] kill -9 -1即实现用kill命令退出系统 Linux主要shell命令详解 [上篇] shell是用户和Linux操作系统之间的接口.Linux中有多种shell,其中缺省使用的 ...

  3. Linux 系统性能监控命令详解

    Linux 系统性能监控命令详解 CPU MEMORY IO NETWORK LINUX进程内存占用查看方法 系统负载过重时往往会引起其它子系统的问题,比如:->大量的读入内存的IO请求(pag ...

  4. (转)linux mount (挂载命令)详解

    linux mount (挂载命令)详解 原文:http://tutu.spaces.eepw.com.cn/articles/article/item/70737 挂接命令(mount) 首先,介绍 ...

  5. [转帖]Linux的wget命令详解

    Linux的wget命令详解 来源不明 找到的也是转帖的 https://www.cnblogs.com/cindy-cindy/p/6847502.html Linux wget是一个下载文件的工具 ...

  6. Linux下ps命令详解 Linux下ps命令的详细使用方法

    http://www.jb51.net/LINUXjishu/56578.html Linux下的ps命令比较常用 Linux下ps命令详解Linux上进程有5种状态:1. 运行(正在运行或在运行队列 ...

  7. Linux下rar命令详解

    Linux下rar命令详解 用法: rar <命令> -<选项1> ….-<选项N> < 操作文档> <文件…> <@文件列表…> ...

  8. linux下tar命令详解

     linux下tar命令详解    tar是Linux环境下最常用的备份工具之一.tar(tap archive)原意为操作磁带文件,但基于Linux的文件操作机制,同样也可适用于普通的磁盘文件.ta ...

  9. Linux下chkconfig命令详解(转)

    Linux下chkconfig命令详解 chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. ...

随机推荐

  1. rabbit--消息持久化

    消息的可靠性是RabbitMQ的一大特色,那么RabbitMQ是如何保证消息可靠性的呢——消息持久化. 为了保证RabbitMQ在退出或者crash等异常情况下数据没有丢失,需要将queue,exch ...

  2. python--3、函数

    定义: 定义函数时,也相当于定义变量.会把函数体内的代码存入开辟的内存空间中.使用函数时,通过func() 声明是函数,其对应的值为代码.函数是指将一组语句的集合通过一个名字(函数名)封装起来,要想执 ...

  3. RecyclerView 通用 Adapter

    先看使用方法

  4. ★Java语法(二)——————————数据类型及装换

    整数类型: 1.byte型:8位(1字节)  范围:-128~127 用法:byte x = 35 : 2.short型:16位(2字节)  范围:-32768~32767 用法:short x = ...

  5. 2、scala条件控制与循环

    1.  if表达式 2.  句终结符.块表达式 3.  输入与输出 4.  循环 5.  高级for循环 1.  if表达式 if表达式的定义:scala中,表达式是有值的,就是if或者else中最后 ...

  6. 蛮好用的局域网测试工具iperf

    公司局域网总是莫名其妙的和一台机器网速很慢,虽然无法解决也无人解决,但是能有个有效的测试至少也会心里有数. 咱干不了网络硬件布线的活,就测测网速吧. 网上找了下,开始有文章介绍NetIQ Chario ...

  7. 【sqli-labs】 less17 POST - Update Query- Error Based - String (基于错误的更新查询POST注入)

    这是一个重置密码界面,查看源码可以看到username作了防注入处理 逻辑是先通过用户名查出数据,在进行密码的update操作 所以要先知道用户名,实际情况中可以注册用户然后实行攻击,这里先用admi ...

  8. OAuth四种模式

    授权码模式(authorization code)----适用于网站服务端去oauth服务端申请授权 简化模式(implicit)----没有服务端,js+html页面去oauth服务端申请授权 密码 ...

  9. MVC控制器返回值

    public ActionResult Index(string id)//主页 //参数string searchString 访问方式为index?searchString=xxxx .参数str ...

  10. SharePoint Designer 2013 开启新式验证(Modern Authentication)

    首先安装office 2013全家桶 再安装SharePoint Designer 2013 安装完之后,去windows检查更新,并把所有需要更新的都更新了 (更新之后我还通过KMS激活了offic ...