天天看点

ifconfig-route-netstat

ifconfig命令

ifconfig -a

ifconfig eth0 [up|down]

ifconfig eth0 172.16.6.14/16 [up]

ifconfig eth0 172.16.6.14/16(16为子网掩码长度)

ifconfig eth0 172.16.6.14 netmask 255.255.0.0

注意:立即生效。

启用混杂模式:[-]promisc

route命令

路由管理命令

查看route -n

添加route add 

route add -host 192.168.1.44 gw 172.16.6.1 dev eth0(目标主机路由)

route add -net  192.168.0.0 netmask 255.255.255.0 gw 172.16.6.1 dev eth0

默认路由,网关:

route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.16.6.1

route add default gw 172.16.6.1

route del -host 192.168.1.44

route del -net 192.168.0.0 netmask 255.255.255.0

DNS服务器指定

/etc/resolv.cnfg

nameserver DNS_IP1

nameserver DNS_IP2

nameserver DNS_IP3

正解: FQDN-->IP

dig -t A FQDN

host -t A FQDN

反解:IP-->FQDN

dig -x IP

host -x IP

netstat:网络状态查看命令

 netstat  - Print network connections, routing tables, interface statis-

       tics, masquerade connections, and multicast memberships

显示网络连接:

netstat -t

netstat -tn

netstat -atn

-t:tcp

-u:udp

-r:raw socket

-l:监听

-a:所有状态

-n:以数字格式显示,不反解

-e:扩展格式的信息

-p:显示相关进程pid

常用组合:

-tan,-uan,-tnl ,-unl

显示路由表

netstat -rn

显示接口统计数据

netstat -i 

netstat -Ieth0

     本文转自阿伦艾弗森 51CTO博客,原文链接:http://blog.51cto.com/perper/1952602,如需转载请自行联系原作者

继续阅读