重启网卡命令:
[root@asm ~]# ifup eth0:1
[root@asm ~]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:8B:86:65
inet addr:192.168.8.162 Bcast:192.168.8.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:75 Base address:0x2000
[root@asm ~]# ifdown eth0:1
[root@asm ~]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:8B:86:65
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:75 Base address:0x2000
route 命令用于设置 Linux 系统的路由信息
查看路由信息:
[root@asm ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.8.1 0.0.0.0 UG 0 0 0 eth0
添加静态路由条目
route add -net netaddress netmask gw ipaddr dev
添加默认网关
route add defalut gw ipaddr
删除一个路由条目
route del -net netaddr netmask gw ipaddr dev
网络诊断工具:
ping 命令可以通过 ICMP 协议对网络进行连接性测试
traceroute 命令可以追踪到达某个目的地所经过的路径
netstat 命令用于查看各种与网络相关的状态信息,其中包括:网络的链接状态、接口的统计信息
查看路由表、端口的监听情况等
[root@asm ~]# traceroute 192.168.8.162
traceroute to 192.168.8.162 (192.168.8.162), 30 hops max, 40 byte packets
1 asm.Oracle.com (192.168.8.160) 3002.781 ms !H 3002.900 ms !H 3002.861 ms !H
[root@asm ~]# traceroute asm.oracle.com
traceroute to asm.oracle.com (192.168.8.160), 30 hops max, 40 byte packets
1 asm.oracle.com (192.168.8.160) 0.300 ms 0.506 ms 0.033 ms
诊断网络是否正常:
wget 下载文件测试
ping
traceroute
curl --head
