Linux Learning log (10)

Source: Internet
Author: User

Network Configuration and Management

Contention for the underlying shared channel

   使用 mac地址(Media Access Control)

Csma/cd

    以太网  载波侦听多路访问/冲突回位

Token Pring

    令牌环   

Hub

     集线器

Conflict domain: All collections that can collide on the underlying device

 网桥:是用来分割冲突域的设备   多接口:交换机

Broadcast domain:

IP Address: 4 segment

32-bit: 1.1.1.1 (octal representation)

 大: 0 000 0000 - 0 111 1111 0-127  中:10 00 0000 -10 11 1111 128~191 小:110 0 0000 -110 1 1111 192~223    1110 0000 -1110 1111 224~239     1111 0000 - 1111 1111 140~255  全0:网络地址  全1:广播地址   

a:1-126

126个网络  127用于回环 2^-1每个网络中的主机:2^24-2默认掩码:255.0.0.0全机位0:网络地址全机位1:广播地址

b:128-191

  2^14个网络  每个网络中的主机2^16-2  默认掩码:255.255.0.0  全0:网络地址   全1:广播地址

c:192-223

   2^21个网络   每个网络中的主机:2^8-2    默认掩码: 255.255.255.0   全0:网络地址   全1:广播地址
For local networks, not for IP addresses on the Internet

Class A:

Class B

16个网络 172.16.0.0/255.255.0.0-172.16.31.0/255.255.0.0

Class C

    256个 192.168.0.0/255.255.255.0-192.168.255.0/255.255.255.0
Subnets, hyper-net

Iana,icnaa

routing table

Static configuration
Dynamic production

Cost: Costs

经过的跳数越少就越小时长        路由协议:RIP,OSPF,EIGRP      可路由协议:IP协议 MAC协议   物理层:物理层协议   ---物理机制   链路层,从设备到设备主机通信 mac地址,IP<--->Mac (ARP/RARP)     |    MTU     |   网络层:从源主机到目标主机之间通信,IP地址,IP报文   传输层:从源主机进程到目标主机特定进程之间的通信TCP/UDP            TCP:0-65535            UDP:0-65535   应用层:标记资源

Port: Used to mark the process

   0-65535Socket(套节字) : IP:port
Basic knowledge of the network

Protocol stack: implemented in the kernel
TCP/IP protocol cluster

Host Name: FQDN

    Full Qulified Domain Name  不是地址,不能通信,让用户记住名字

Name resolution: DNS

IP Header

ip--vserison--首部长度--报文服务类型--总长度-  -Identification (FragmentID)-Fragment Offset-   -Time-To-Live--Protocol(协议类型)--Header Checksum (首部校验)--源IP--目的IP--核心内容--数据          

Mtu:

 Maximum Rranslate  

Fragment:ip Shards
Fragment offset Offsets

Configuring hosts to intervene in TCP/IP networking

Ip/netmask
Routing:

 主机路由:一台主机 网络路由:网络 默认路由:default

DNS Server

     主DNS服务器     备用DNS服务器

Host Name

 静态指定 :      IP/Netmask 动态配置 :     
Configure IP

User Space tools:

      ifconfig      ip

Network Device service configuration file

  1./etc/sysconfig/network-script/ifcfg-eth0  2.GUI

How network devices represent

内核识别设备:驱动设备:别名以太网设备:ethX     eth0,eth1,eth2.....ppp网络: pppX本地回环: lo  

Command-line tools for user space: Effective immediately, when not long-lasting

 ifconfig iproute2(ip,ss)
Ifconfig

Ifconfig IP Addr IP link

ifconfig:显示所有活动状态的相关信息ifconfig Interface:仅显示指定接口的相关信息if config Interface Address    ip/mask:        长格式 255.255.0.0        CIDR:16                ifconfig Interface IP/MASK
Route

Route:ip Route

route:显示路由信息    -n:使用数字格式显示,不反解地址到主机名route add:  -host HOST_IP gw Next [dev Device]  -net Net_ADDR  -net 0.0.0.0 目标地址为任意地址route del     -host HOST_IP gw 下一跳     -net Net_ADDR gw 下一跳

DNS server points to

配置文件:/etc/resolv.conf             最多三个:  nameserver DNS_SERVER_IP  dig -t A 域名     正解测试  dig -x IP      反解测试

Scripting services: SysV style LSB

  多数为控制运行于后台守护进程,接受参数{start|stop|restart|satus}  脚本位置 /etc/rc.d/init.d/ 或/etc/init.d/  配置某服务开机自动启动 chkconfig Srv_Script_Name on    禁止开机自动启动:chkconfig Srv_Script_Name off   查看  chkconfig --list[Srv_Script_Name]  (关注3和5) 调用机制:  1./etc/init.d/Script_Name {start|stop|restart|status}  1.service Script_Name {start|stop|restart|status}
Service control scripts related to network devices

They are usually able to read the configuration files configured for the network to enable management functions such as their configuration to take effect or fail.

 配置文件有两类(/etc/sysconfig/network-scripts/):     配置IP,掩码,网关:        以太网:ifcfg-ethX        ppp:ifcfg-pppX       配置路由          route-ethX          route-pppX

Configure IP, mask, Gateway: EthX

  DEVICE="eth0"    此配置关联至的设备。设备名要与文件ifcfg-后ude内容保持一致  BOOTPROTO=none       引导协议:{none|static|dhcp|bootp}  HWADDR="00:0C:29:26:62:92"        MAC地址:要与真实MAC地址保持一致,可省略  NM_CONTROLLED="yes"        是否接受NetworkManager脚本控制:{yes|no}  ONBOOT="yes"       是否开机自动启动此网络设备{yes|no}  TYPE="Ethernet"        设备类型Etheraget Bridge(桥接)  UUID="14351f7f-a726-4dfc-966e-dfb1f352f226"      唯一标识,可省略  IPADDR=     ip地址  NETMASK=    掩码  GATEWAY=    默认网关  DNS1=     DNS1服务地址  IPV6INIT=no     是否开启ipv6  USERCTL=no     是否允许普通用户操作网卡  PEERDNS={yes|no}     是否允许DHCP服务分配地址时直接更新/etc/resolv。conf中的DNS服务器地址

Configure routing: ROUTE-ETHX

   配置文件的格式1:每行一个要配置的路径条目   目标 via 下一跳 配置文件的格式2:每一组一个路由条目   ADDRESS#=目标   NETMASK#=掩码   GATEWAY#=下一跳

How to configure multiple addresses on a single interface:

 通过网络接口别名来实现       eth0X       eth0:X eth0:0 eth0:1.... 配置1:    ifconfig ethX:Y IP/mask 配置2:          ifcfg-ethX:Y          DEVICE=ethX:Y          BOOTPROTO={none|static}          IPADDR=          NETMASK=          GATEWAY=          ONBOOT=          USERCTL=       非主地址不支持DHCP协议获取     
Use of IP commands

IP link

ip link show 查看默认信息ip link set 接口 [up|down] [multicast on|off]:

IP addr

  可以在一个接口配置多个地址而不使用接口别名:显示这些地址    ip addr show    ip addr add dev 接口 ip地址/掩码 [ ladel 别名 ]     ip addr add dev 接口 ip地址 [ ladel 别名 ]    ip addr flush 接口 [to 网络地址]

IP route

 ip route add 目标 via 下一跳 ip  [src ip][dev 设备] ip route del 目标 ip route show

Enable/Disable interface:

  ip link set 接口 up|down  ifconfig 接口 up|down  ifdown 接口,ifup 接口     重置网络连接

Tui or GUI

 system-config-network-tui    配置结束后将保存配置文件中 setup --> Network Configuration
Tools related to network management or detection:

ping:icmp

   ping [options] ip     -c 次数     -w 测试执行时长

Traceroute HOST:

    获取当前主机到目标主机所经过的网关

MTR HOST

Netstat

   -t:tcp协议的连接   -u:udp协议的链接   -l:监听状态的连接   -a:所有状态的连接   -p:连接相关的进程   -n:数字格式显示   -r: 显示路由表,类似于route或ip route show   常用组合:    netstat -tan    netstat -tunl    netstat -rn

SS, used to replace Netstat

   -t:tcp协议的连接   -u:udp协议的链接   -l:监听状态的连接   -a:所有状态的连接   -e:显示扩展信息   -m:显示套接连接使用的内存信息   -p:进程及UDP   -n:数字格式显示   

Ethtool

  ethtool 接口: 显示接口设备属性  

Extracurricular tasks:
Nmap: Scanners
Tcpdump: Sniffer
Wireshark: Sniffer
Tshark: The character interface

Script:
1. Use the ping command to detect which hosts are online 172.16.0.0/16
Online, shown in green
Not online, shown in red

 #!/bin/bash for i in {0..255};do    for j in {1..254};do        ping -c 1 172.16.$i.$j &> /dev/null       if [[ $? -eq 0 ]];then         echo -e -n "\033[32mping 172.16.$i.$j ke da !\033[0m\n"       else         echo -e -n "\033[31mping 172.16.$i.$j bu ke da !\033[0m \n"       fi    donedone

Linux Learning log (10)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.