计算机网络

当一个交换机上的所有端口中有至少一个端口属于不同网段的时候,当路由器的一个物理端口要连接2个或者以上的网段的时候,就是VLAN发挥作用的时候,这就是VLAN的目的。

*************************************************************************

面向连接和无连接服务:

面向连接服务:如电话,TCP。传输按序进行、可靠性高、有连接开销、适用于一定时间内向同一目的地发送多组报的情形;

无连接服务:如短信,UDP。不管对方状态,直接发送。可靠性差、可能导致报文丢失、乱序、重复等。但通信迅速,无连接开销。


TCP建立连接的三次握手过程


*************************************************************************

路由表:

1- 目的地址(网络地址或主机地址)

2- 网络掩码

3- 下一跳地址(路由器IP或直连网络地址)

4- 标志(指明1和3项分别属于哪种情况)

5- 网络接口

路由表是用来决定如何将包从一个子网传送到另一个子网的,换句话说就是用来决定从一个网卡接受到的包应该送到哪一个网卡上去。路由表的每一行至少由目标网络号、netmask、到这个子网应该使用的网卡这3条信息。当路由器从一个网卡接受到一个包时,它扫描路由表的每一行,用里面的netmask和包里的目标IP地址做并逻辑运算(&)找出目标网络号。如果此网络号和这一行里的网络号相同,就将这条路由保留下来作为备用路由。如果已经有备用路由了,就在这两条路由里将网络号最长的留下来,另一条丢掉。如此接着扫描下一行直到结束。如果扫描结束仍没有找到任何路由,就用默认路由。确定路由后,直接将包送到对应的网卡上去。

*************************************************************************

linux网络相关指令:

(1)route add default gw<默认路由器IP>

(2)ifconfig 网络端口 IP地址 hw <HW> MAC地址 netmask 掩码地址 broadcast 广播地址 [up/down]

 ifconfig eth1 192.168.1.252 hw ether 00:11:00:00:11:11 netmask 255.255.255.0 broadcast 192.168.1.255 up

其中 hw 后面所接的是网络接口类型, ether表示以太网;up/down表示打开或关闭网口接口

(3)netstat:

 (none)

       By  default,  netstat  displays  a  list ofopensockets.  If you don't
       specify any address families, then the active sockets of all configured
       address families will be printed.

--route , -r
       Display  the kernel routing tables. See the description in route(8) for
       details.  netstat -r and route -e produce the same output.

--interfaces, -i
       Display a table of all network interfaces.

--statistics , -s
       Display summary statistics for each protocol.

--numeric , -n
       Show numerical addresses instead of trying to determine symbolic  host,
       port or user names.

-c, --continuous
       This will cause netstat to print the selected information every  second
       continuously.

-o, --timers
       Include information related to networking timers.

-p, --program
       Show the PID and name of the program to which each socket belongs.

-l, --listening
       Show only listening sockets.  (These are omitted by default.)

-a, --all
       Show both listening and non-listening sockets.  With  the  --interfaces
       option, show interfaces that are not up

(4) route:配置并查看内核路由表的配置情况。
-添加到主机的路由
#route add –host 192.168.1.2 eth0  //主机192.168.1.2通过eth0“直连”,直连包括通过交换机连接的情况?!
#route add –host 10.20.30.148 gw 10.20.30.40 //主机10.20.30.148通过10.20.30.40路由器,10.20.30.40在哪个接口,通过其他路由表项搜索
-添加到网络的路由
#route add –net 10.20.30.40 netmask 255.255.255.248 eth0
#route add –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
#route add –net 192.168.1.0/24 eth1
-添加默认网关
#route add default gw 192.168.1.1
-查看内核路由表的配置。
#route
-删除路由。
#route del –host 192.168.1.2 dev eth0:0
#route del –host 10.20.30.148 gw 10.20.30.40
#route del –net 10.20.30.40 netmask 255.255.255.248 eth0
#route del –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
#route del –net 192.168.1.0/24 eth1
#route del default gw 192.168.1.1

EXAMPLES of man page:

       route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
              adds the normal loopback  entry,  using  netmask  255.0.0.0  and
              associated with the "lo" device (assuming this device was previ‐
              ously set up correctly with ifconfig(8)).

       route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
              adds a route to the local network 192.56.76.x via  "eth0".   The
              word "dev" can be omitted here.

       route del default
              deletes the current default route, which is labeled "default" or
              0.0.0.0 in the destination field of the current routing table.

       route add default gw mango-gw
              adds a default route (which will  be  used  if  no  other  route
              matches).   All  packets  using  this  route  will  be gatewayed
              through "mango-gw". The device which will actually be  used  for
              that  route  depends on how we can reach "mango-gw" - the static
              route to "mango-gw" will have to be set up before.

       route add -net 10.0.0.0 netmask 255.0.0.0 reject
              This   installs  a  rejecting  route  for  the  private  network
              "10.x.x.x."

*************************************************************************

全零(“0.0.0.0”)地址对应于当前主机。全“1”的IP地址(“255.255.255.255”)是当前子网的广播地址



*************************************************************************

保留的私有ip地址:

       10.x.x.x
  172.16.x.x至172.31.x.x
  192.168.x.x

*************************************************************************

组播(multicast)是一种允许一个或多个发送者(组播源)发送单一的数据包到多个接收者(一次的,同时的)的网络技术。组播可以大大的节省网络带宽,因为无
论有多少个目标地址,在整个网络的任何一条链路上只传送单一的数据包。所以说组播技术的核心就是针对如何节约网络资源的前提下保证服务质量。

*************************************************************************

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值