[TOC]
curl 1 2 3 4 # 设置代理的2种方法 > env http_proxy=http://localhost:8080 curl -I http://google.com > curl --proxy http://localhost:8080 https://example.com
curl网站开发指南
问:ip命令来自哪个包 答:ip 命令来自于 iproute2 安装包,一般系统会默认安装,如果没有的话,请读者自行安装
问:服务名称与port number的对应在Linux当中,是用那个文件来设定对应的? 答:/etc/services
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ➜ ~ cat /etc/resolv.conf # This file is not consulted for DNS hostname resolution, address # resolution, or the DNS query routing mechanism used by most # processes on this system. # # To view the DNS configuration used by this system, use: # scutil --dns # # SEE ALSO # dns-sd(1), scutil(8) # # This file is automatically generated. # nameserver 202.101.172.35 nameserver 202.101.172.47
route host, nslookup 侦测主机名与IP对应
host这个指令可以用来查出某个主机名的IP喔! 范例一:找出tw.yahoo.com的IP
1 2 3 4 5 6 ➜ ~ host tw.yahoo.com tw.yahoo.com is an alias for atsv2-fp-shed.wg1.b.yahoo.com. atsv2-fp-shed.wg1.b.yahoo.com has address 124.108.103.103 atsv2-fp-shed.wg1.b.yahoo.com has address 124.108.103.104 atsv2-fp-shed.wg1.b.yahoo.com has IPv6 address 2406:2000:ec:815::3 atsv2-fp-shed.wg1.b.yahoo.com has IPv6 address 2406:2000:ec:815::4
范例一:找出www.google.com的IP
1 2 3 4 5 6 7 ➜ ~ nslookup www.google.com Server: 202.101.172.35 Address: 202.101.172.35#53 Non-authoritative answer: Name: www.google.com Address: 64.13.192.76
1 2 3 4 5 6 7 8 9 ➜ ~ nslookup 64.13.192.76 Server: 202.101.172.35 Address: 202.101.172.35#53 Non-authoritative answer: 76.192.13.64.in-addr.arpa name = acmkokecgc.gs01.gridserver.com. Authoritative answers can be found from:
netstat netstat的输出主要分为两大部分,分别是TCP/IP的网络接口部分,以及传统的Unix socket部分。
基本上,我们常常谈到的netstat的功能,就是在观察网络的联机状态了,而网络联机状态中,又以观察『我目前开了多少的port在等待客户端的联机』以及『目前我的网络联机状态中,有多少联机已建立或产生问题』最常见。
Unix socket通常是用在一些仅在本机上运作的程序所开启的插槽接口文件,例如X Window不都是在本机上运作而已吗?那何必启动网络的port呢?当然可以使用Unix socket啰,另外,例如Postfix这一类的网络服务器,由于很多动作都是在本机上头来完成的,所以以会占用很多的Unixsocket喔!
netstat – show network status netstat命令显示各种网络相关的数据结构。 对于显示的信息,依据选项,有多种输出格式。 第一种格式:显示各种协议所有的sockets 第二种格式:根据所选择的选项显示其他网络数据结构之一的内容 第三种格式:在指定等待间隔的情况下,netstat将在配置的网络接口上连续显示有关数据包流量的信息 第四种格式:显示指定协议或地址系列的统计信息。如果指定了等待间隔,将显示最后一个间隔的协议信息 第五种格式:显示指定协议或地址系列的每个接口统计信息 第六种格式:显示mbuf(9)统计信息 第七种格式:显示指定地址系列的路由表 第八种格式:显示路由统计信息
1 2 3 4 5 6 7 8 netstat [-AaLlnW] [-f address_family | -p protocol] netstat [-gilns] [-v] [-f address_family] [-I interface] netstat -i | -I interface [-w wait] [-c queue] [-abdgqRtS] netstat -s [-s] [-f address_family | -p protocol] [-w wait] netstat -i | -I interface -s [-f address_family | -p protocol] netstat -m [-m] netstat -r [-Aaln] [-f address_family] netstat -rs [-s]
1 2 3 4 # 与路由有关的参数 # -r 列出路由表,功能如同route这个指令 # -n 不使用主机名与服务名称,使用IP与port number,如同route -n netstat -[rn]
1 2 3 4 5 6 7 #范例一:列出目前的路由表状态,且以IP及port number显示: ➜ ~ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 10.211.55.1 0.0.0.0 UG 0 0 0 enp0s5 10.211.55.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s5 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 enp0s5
1 2 3 #范例二:列出目前的网络联机状态,且以IP及port number显示: # -a:列出所有的联机状态,包括tcp/udp/unix socket等 ➜ ~ netstat -an
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #范例三:列出目前已启动的网络服务: #最重要的其实是那个-l的参数,因为可以仅列出有在Listen的 ➜ ~ netstat -tulpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.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 0.0.0.0:80 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN - tcp6 0 0 ::1:631 :::* LISTEN - tcp6 0 0 :::8080 :::* LISTEN - udp 0 0 0.0.0.0:35144 0.0.0.0:* - udp 0 0 127.0.1.1:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 0.0.0.0:40666 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp6 0 0 :::50198 :::* - udp6 0 0 :::33848 :::* - udp6 0 0 :::5353 :::* - udp6 0 0 :::5353 :::* -