一、网络基础知识
IP地址犹如互联网上机器的门牌号, 各机器通过ip地址进行通信。 IP地址分为5大类,分为a类、b类、c类、d类和e类, 它将32类的ip地址分为三段,第一段为各类标识,第二段分为网络号,第三段为主机号。
相关命令:ipconfig/ifconfig, 用ping命令也可以看到服务器的ip。
linux上查看, 使用
traceroute
如果需要自己为之分配ip地址,需要切换为手动分配ip的状态, 再去修改文件
/etc/sysconfig/network-scripts/ifcfg-eth0,保存之后使用
/etc/rc.d/init.d/network restart使之生效。
[root@oracle11g ~]# ping www.sina.com
PING jupiter.sina.com.cn ( 61.172.201.194) 56(84) bytes of data.
64 bytes from 61.172.201.194: icmp_seq=1 ttl=246 time=9.60 ms
64 bytes from 61.172.201.194: icmp_seq=2 ttl=246 time=18.9 ms
64 bytes from 61.172.201.194: icmp_seq=3 ttl=246 time=16.6 ms
64 bytes from 61.172.201.194: icmp_seq=4 ttl=246 time=36.5 ms
PING jupiter.sina.com.cn ( 61.172.201.194) 56(84) bytes of data.
64 bytes from 61.172.201.194: icmp_seq=1 ttl=246 time=9.60 ms
64 bytes from 61.172.201.194: icmp_seq=2 ttl=246 time=18.9 ms
64 bytes from 61.172.201.194: icmp_seq=3 ttl=246 time=16.6 ms
64 bytes from 61.172.201.194: icmp_seq=4 ttl=246 time=36.5 ms
在windows上检查到达目的服务器的路由经过, 使用tracert; 在linux上面使用traceroute命令。
C:\Users\tjwkj>
tracert www.baidu.com
通过最多 30 个跃点跟踪
到 www.a.shifen.com [119.75.213.61] 的路由:
1 4 ms 3 ms 5 ms 61.130.120.84
2 10 ms 3 ms 3 ms 61.130.120.84
......
12 51 ms 47 ms 55 ms 119.75.213.61
跟踪完成。
通过最多 30 个跃点跟踪
到 www.a.shifen.com [119.75.213.61] 的路由:
1 4 ms 3 ms 5 ms 61.130.120.84
2 10 ms 3 ms 3 ms 61.130.120.84
......
12 51 ms 47 ms 55 ms 119.75.213.61
跟踪完成。
[root@oracle11g ~]#
traceroute www.baidu.com
traceroute to www.baidu.com (119.75.213.61), 30 hops max, 40 byte packets
1 * * *
2 * * *
......
30 * * *
traceroute to www.baidu.com (119.75.213.61), 30 hops max, 40 byte packets
1 * * *
2 * * *
......
30 * * *
本地回路:只要第一个字节为127开始则可,不一定要使用127.0.0.1(后3个字段全0全1除外)
[root@oracle11g ~]#
ping 127.123.234.213
PING 127.123.234.213 (127.123.234.213) 56(84) bytes of data.
64 bytes from 127.123.234.213: icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from 127.123.234.213: icmp_seq=2 ttl=64 time=0.086 ms
64 bytes from 127.123.234.213: icmp_seq=3 ttl=64 time=0.055 ms
64 bytes from 127.123.234.213: icmp_seq=4 ttl=64 time=0.084 ms
PING 127.123.234.213 (127.123.234.213) 56(84) bytes of data.
64 bytes from 127.123.234.213: icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from 127.123.234.213: icmp_seq=2 ttl=64 time=0.086 ms
64 bytes from 127.123.234.213: icmp_seq=3 ttl=64 time=0.055 ms
64 bytes from 127.123.234.213: icmp_seq=4 ttl=64 time=0.084 ms
二、Linux下网络的配置
方法1: 以root登陆后使用
setup命令(该命令可以配置很多内容,包括防火墙、IP、各种Service、授权等),修改ip之后保存退出再查询ip地址,此时发现ip地址还没有生效,使用命令
/etc/rc.d/init.d/network restart重启网络后就生效了。
方法二:使用
ifconfig etho0 *.*.*.*对网卡进行设置。此为立即生效,重启后则消失, 即为临时生效。 使用ifconfig etho0 network *.*.*.*对子网掩码进行设置。
方法三:修改
/etc/sysconfig/network-scripts/ifcfg-eth0
以下为动态获取ip的配置情况, 它有操作系统来分配的:
[root@oracle11g ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:CD:0B:4F
ONBOOT=yes
[root@oracle11g ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:CD:0B:4F
ONBOOT=yes
本文转自 tianya23 51CTO博客,原文链接:http://blog.51cto.com/tianya23/267177,如需转载请自行联系原作者