1.ifconfig用法:
ifconfig [interface] ifconfig interface [aftype] options | address ... ifconfig #默认列出处于开启状态的网卡信息 ifconfig -a #列出所有的网卡信息,无论处于开启或关闭状态 ifconfig eth0 #仅列出eth0的信息 ifconfig eth1 down #关闭eth1 ifconfig eth1 up #开启eth1 ifconfig eth1 192.168.56.100 #给网卡设定临时ip地址 ifconfig eth1 192.168.56.100 netmask 255.255.255.0 mtu 8000 ifconfig eth1:0 10.0.0.0 #给一个网卡配置多个ip地址,使用网卡别名。
2.网络配置文件:
/etc/sysconfig/network-scripts/ifcfg-eth0
vim /etc/sysconfig/network-scripts/ifcfg-eth0 #该文件的主要配置内容: DEVICE="eth0" #网卡名,一般与ifcfg-后面的部分相同 BOOTPROTO="dhcp" #取得ip的方式,可以设定为none|bootp|dhcp HWADDR="08:00:27:B6:87:89" #网卡的mac地址 ONBOOT="yes" #默认是否启动此接口,yes|no IPADDR=192.168.56.102 #静态设置ip地址 NETMASK=255.255.255.0 #设置子网掩码 GATEWAY=192.168.56.1 #默认路由 #常用配置上面这几项,具体的看参考文件: /usr/share/doc/initscripts-9.03.31/sysconfig.txt
/etc/sysconfig/network :
vim /etc/sysconfig/network NETWORKING=yes #是否开启本机网络 HOSTNAME=zhu #主机名
3.ping指令的使用:
ping [参数] ip -c count #后面跟ping的次数,如-c 3 -W timeout #指定超时的时间 [root@zhu ~]# ping -c 3 192.168.0.70 PING 192.168.0.70 (192.168.0.70) 56(84) bytes of data. 64 bytes from 192.168.0.70: icmp_seq=1 ttl=63 time=4.45 ms 64 bytes from 192.168.0.70: icmp_seq=2 ttl=63 time=2.94 ms 64 bytes from 192.168.0.70: icmp_seq=3 ttl=63 time=3.26 ms --- 192.168.0.70 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2007ms rtt min/avg/max/mdev = 2.949/3.554/4.453/0.648 ms [root@zhu ~]# ping -c 3 -W 2 192.168.0.70 PING 192.168.0.70 (192.168.0.70) 56(84) bytes of data. 64 bytes from 192.168.0.70: icmp_seq=1 ttl=63 time=4.49 ms 64 bytes from 192.168.0.70: icmp_seq=2 ttl=63 time=2.53 ms 64 bytes from 192.168.0.70: icmp_seq=3 ttl=63 time=2.28 ms --- 192.168.0.70 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2007ms rtt min/avg/max/mdev = 2.284/3.105/4.492/0.986 ms
转载于:https://blog.51cto.com/zhujiangtao/1390313