Ax Introduction
Linux network configuration and such command.
Bx ifconfig
ifconfig | cut -c-10 | tr -d ' ' | tr -s '\n'     # 打印网络接口列表
ifconfig Interface IPA netmask maskvalue          # 手动配置网络接口的IP和子网掩码
dhclient Interface                                  # 自动配置网络接口
ifconfig Interface | egrep -o "inet addr:[^  ]*" | grep -o "[0-9]*" # 提取IP地址
ifconfig Interface hw ether 00:1c:bf:87:25:d5     # MAC地址欺骗
Cx DNS
cat /etc/resolv.conf                             # 读取服务器名字
echo nameserver IPA >> /etc/resolv.conf             # 添加服务器名字
ping domain                                         # 得到域名IP
host domain                                         # 域名所有IP
nslookup domain                                     # 域名IP解析信息
echo IPA symbolicname >> /etc/hosts              # 添加解析条目
Dx Route
route -n                                         # 数字的形式
route add default gw IPA Interface               # 设置默认网关
Ex ICMP(ping&traceroute)
ping IPA                                         # 检查是否可达
ping -c number                                     # 次数
fping -a IPA/mask -g                             # ping网段,-a 有效 -u 无效
traceroute domain                                # 节点检测
使用ping也可以检查网段存活主机,可以编写脚本如下:
#!/bin/bash
for ip in 192.168.0.{1..255} ;
do
    ping $ip -c 2 &> /dev/null ;
    
    if [ $? -eq 0 ];
    then
        echo $ip is alive
    fi
done

但是ping的这个脚本还是不及fping的速度啊,及其的慢。
改进版:并发ping
#! /bin/bash
for ip in 192.168.0.{1..255};
do
    (
        ping $ip -c2 &> /dev/null;
        if [ $? -eq 0 ];
        then
                echo $ip is alive
                fi
    )&
    done
wait

速度明显快多了,但是还是不及fping啊
 
                     
                     
                        
                        