linux网络基础

以太网的发明:pc之间文件共享的情况出现

一层:物理层

网卡硬件设备:MAC地址

HUB  集线器   总线型结构    泛洪

       广播域/冲突域

二层

早期pc间只需要MAC地址,就可以互相共享,数据转发

网桥--交换机  维护MAC地址表

三层:网络层

随着网络增大,需要接入网络的设备越来越多;这时候,产生了逻辑地址

ipv4 ipv6 IPX  ApplleTalk Novell DEC  都是早期的逻辑地址

网段互联   路由可达

路由器  路由表

四层:传输层

核心任务--关联进程

       应用端口:

                     TCP:1-1023 1024-65535

                            20 21 22 23 25 53 80 443 110 111

                     UDP

                            67 68 69

五层:应用层

       程序应用

              访问网络资源的过程

              pc的网络资源--内核空间管理

              应用层通讯

                     pc内部的进程通讯  1.父子进程通讯 2.single信号通讯

                     pc之间的进程通讯  1.rpc  2.套接字socket

关于主机控制网络的命令:

       ifcfg家族的命令:ifconfig netstat  route

              ifconfig:

                            ifconfig 显示当前up的端口

                            ifconfig eh0  显示指定端口

                                   -a 查看所有地址

                            ifconfig eth0 add address netmask 255.255.255.0

                                   添加一个IP地址给eth0

                            ifconfig interface address netmask 【up/down】

                            ip地址配置后立即生效 ,但重启网卡后,恢复原来的ip

                            过滤mac地址:ifconfig|grep -o --color=auto "\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}

              route:

                     查看以及添加路由

                     route -n 查看所有路由不做解析。

                     U up

                     G  网关路由

                     H  主机路由

                     添加路由

                                   1.添加默认路由(网关)

                                          route add default gw 192.168.92.1

                                   2.添加主机路由

                                          route add-host 192.168.95.95.95 dev eth0

                                   3.添加路由网段

                                          route add -net 192.168.95.0 netmask 255.255.255.0 eth0

                     删除路由:

                                   del -net

                                   del -host

              netstat:

                     一般查看内容:

                            -t  tcp

                            -n  不解析

                            -a  -tcp协议标记位(syn、Ack、seq、req) listen establish

                            -l listen

                            -e enstablish

                            -p program

                     查看路由内容

                            -r  --route

                     进行数据统计

                            netstat -I 统计接口显示情况

                            -v

                            -e

ip家族命令  ip  ss

       ip 命令是ifconfig的更加新的命令,功能要比ifocnfig更强大

       ip [option] object {command|help}

              object

                     link

                            add

                            del

                            set

                                   ip link set dev {up|down}

                                   ip link set arp {on|off}

                                   ip link set dev dymic {on|off}

                            show

                     addr

                            add  默认添加备用地址

                            replace change

                            del  只能删除一个地址 IP addr del 192.168.94.200/24 Dev eth0:0

                            flush 指定一类地址同时清除掉

                                   IP addr flush  dev eth0 清楚了所有的地址

                            show

                     route

                            add

                                   IP route add 192.168.95.0/24 via 192.168.94.2

                                   ip route add 192.168.95.95 dev eth0

                            del

                            flush

                                   IP route flush dev eth0 (删除所有路由 不建议使用)

                            show

图形化界面:

       system-config-network-tui

       setup

配置文件:

       /etc/sysconfig/network-scripts/ifcfg-名字

              device="名字"

              hwaddr=ff:ff:ff:ff:ff

              bootproto={static}dhcp|nano}

              ipaddr=192.168.1.1

              netmask=255.255.255.0

              prefix=24

              getway=192.168.1.2

              dns1=

              dns2=

              dns3=

              type=Ethernet|Bridge

              onboot=

              userctl   //是否容许普通用户修改该网卡参数,一般关闭

              uuid=

       /etc/sysconfig/network-scripts/route

              第一种:

                     192.168.0.0/24 via 172.16.0.1

                     /etc/init.d/network restart

                     route -n //就能看到

              第二种:

                     ADDRESS0=192.168.20.0

                     NETMASK0=255.255.255.0

                     GATWAY0=172.16.0.1

                    

posted @ 2019-09-03 16:14  Sean_Martin  阅读(389)  评论(0编辑  收藏  举报