icmp

icmp实现ping

孤街浪徒 提交于 2020-01-01 03:41:50
以前弄到的一段代码, 一个用原始套接字raw socket实现icmp协议ping工具 myping.c #include <stdio.h> #include <errno.h> #include <signal.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <sys/time.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <netinet/ip_icmp.h> #define ICMP_PACKET_SIZE 16 #define TIME_OUT_SECONDS 2 unsigned short cal_chksum(unsigned short *buf, int len) { unsigned int sum = 0; unsigned short ret; while(len > 1) { sum += *buf; buf++; len -= 2; } if(1 == len) { sum +

重装上了Fedora8自带的MySQL5.0.45,再试,告捷!!

最后都变了- 提交于 2020-01-01 02:45:11
MySql服务器IP是192.168.0.104,测试连接的笔记本IP为192.168.0.100. 以下命令说明两台机器的网络连接是通畅的: [root@bogon bin]# ping 192.168.0.100 PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data. 64 bytes from 192.168.0.100: icmp_seq=1 ttl=128 time=9.26 ms 64 bytes from 192.168.0.100: icmp_seq=2 ttl=128 time=3.85 ms 64 bytes from 192.168.0.100: icmp_seq=3 ttl=128 time=6.85 ms 64 bytes from 192.168.0.100: icmp_seq=4 ttl=128 time=4.25 ms 64 bytes from 192.168.0.100: icmp_seq=5 ttl=128 time=10.4 ms 64 bytes from 192.168.0.100: icmp_seq=6 ttl=128 time=8.26 ms 64 bytes from 192.168.0.100: icmp_seq=7 ttl=128 time=3.24 ms 64

iptables

独自空忆成欢 提交于 2019-12-31 16:52:00
目录 linux防火墙 安全技术和防火墙 安全技术 防火墙的分类 netfilter 中五个勾子函数和报文流向 iptables 用法说明 Target iptables规则安排的基本原则 linux防火墙 安全技术和防火墙 安全技术 入侵检测与管理系统(Intrusion Detection Systems):特点是不阻断任何网络访问,量化、定位来自内外网络的威胁情况,主要以提供报告和事后监督为主,提供有针对性的指导措施和安全决 策依据。一般采用旁路部署方式 入侵防御系统(Intrusion Prevention System):以透明模式工作,分析数据包的内容如:溢出攻击、拒绝服务攻击、木马、蠕虫、系统漏洞等进行准确的分析判断,在判定为攻击行为后立即予 以阻断,主动而有效的保护网络的安全,一般采用在线部署方式 防火墙( FireWall ):隔离功能,工作在网络或主机边缘,对进出网络或主机的数据包基于一定 的规则检查,并在匹配某规则时由规则定义的行为进行处理的一组功能的组件,基本上的实现都是 默认情况下关闭所有的通过型访问,只开放允许访问的策略 防火墙的分类 按保护范围划分: 主机防火墙:服务范围为当前主机 网络防火墙:服务范围为防火墙一侧的局域网 按实现方式划分: 硬件防火墙:在专用硬件级别实现部分功能的防火墙;另一个部分功能基于软件实现,如:华为,

Difference between struct ip and struct iphdr

…衆ロ難τιáo~ 提交于 2019-12-31 10:52:23
问题 I am trying to understand how the network is working, i'm doing some test, sending some package... anyway My point is that i can't find the real difference between "protocol" structure and "protocol header" structure . For the ip structure, they both sized 20 bytes. but for exemple: struct ip and struct iphdr sized 20 bytes struct icmp sized 28 bytes struct icmphdr sized 8 bytes I'm guessing that the struct icmp include a struct ip/iphdr? ? And there is the same kind of structure with every

Difference between struct ip and struct iphdr

笑着哭i 提交于 2019-12-31 10:51:08
问题 I am trying to understand how the network is working, i'm doing some test, sending some package... anyway My point is that i can't find the real difference between "protocol" structure and "protocol header" structure . For the ip structure, they both sized 20 bytes. but for exemple: struct ip and struct iphdr sized 20 bytes struct icmp sized 28 bytes struct icmphdr sized 8 bytes I'm guessing that the struct icmp include a struct ip/iphdr? ? And there is the same kind of structure with every

网络虚拟化

徘徊边缘 提交于 2019-12-28 13:40:42
介绍 https://segmentfault.com/a/1190000004059167 在专业的网络世界中,经常使用到Virtual Routing and Forwarding(VRF),比如Cisco,Alcatel-Lucent, Juniper 等。对于L2 switch,自从上世纪90年代就开始使用VLAN,一个物理交换机上可以使用多个广播域,如今大多数交换机都支持4K vlan。 这个概念被引入到L3,如今很多网络设备支持VRF。这意味着,单个物理设备上可运行多个虚拟路由(L3 转发实例)。 在linux中,VRF被叫做“network namespace”。 每个network namespace拥有其对应的路由表(routing table)& 其对应的iptables,并且运行程序运行其中。 为什么有人使用它?比如一个运行在linux上的 Firewall,将firewall的所有服务端口分配给一个network namespace,这样,默认的network namespace 和 Firewall network namespace就运行着不同的路由表。像SSH这样的application运行在默认的network namespace,但是不在Firewall network namespace。 下面展示了其基本用法。 Basic network

kali信息主动收集之三层发现

安稳与你 提交于 2019-12-28 11:38:42
三层发现 优点可路由 速度比较快 缺点 速度比二层慢 经常被边界防火墙过滤 是IP、icmp协议(网络控制管理,路径发现网络发现诊断的协议) ping命令 ping IP -c 指定包数 用这个命令发到指定的包数之后就会结束发包 当我们如果探测一个目标机器可以ping他 他会返回ICMP的数据包还有一个办法就是路由追踪的方式可以作到探测目标机器在线或者离线 还可以发现从我的机器到目标机器经过了多少跳的路由。 用traceroute 域名 可以实现路由追踪 边界防火墙过滤的反应就是会变成三个星号 打开wireshark抓包 当Time-to-live 值超过最大数的时候他就会返回数据包 每经过一跳Time-to-live值就会减一 基于这个方式把路径上的所有方式都发现出来 Time-to-live变0了他就会给我回包了 ping -R 域名 使用这个命令也可以实现路由的追踪 记录从我的电脑到目标IP路径上的每一跳的IP地址但是和traceroute 显示的信息是不一样的如果没有受到限制traceroute是发现离我近的内网口IP地址,ping-R就是发现远的外网口IP地址。 ping命令加管道可以显示IP地址 ping命令不支持网段扫描所以要写shell脚本对IP地址段进行扫描 ping IP地址 -c 1 | grep -“bytes from” | cut -d " " - f

5.ICMPv4协议分析与实践

孤人 提交于 2019-12-28 04:42:37
ICMPv4 协议分析与实践 1. 概述 1.1 ICMP 简介 ICMP(Internet Control Message Protocol) : 用于 IP 中发送控制消息( 不可靠 ),提供可能发生在通信环境中的各种问题反馈,通常用于返回的错误信息或是分析路由。 依靠 IP 完成任务,但一般不用于在两点之间传输数据,通常不由网络程序直接使用,除了 ping 和 traceroute 1.2 ICMPv4 报文格式 类型 说明 代码 3 目的不可达消息 0 网络不可达 1 主机不可达 2 协议不可达 3 端口不可达 4 需要分片,但是设置了 DF 5 源路由失败 5 重定向消息 0 对网络重定向 1 对主机重定向 2 对服务类型和网络重定向 3 对服务类型和主机重定向 8/0 ping 请求和 ping 应答 11 超时消息 0 传输超时,即 TTL 为 0(tracetoute 原理) 1 分片重组超时,重组定时器超时了,还有分片没到达 12 参数问题消息 0 IP 首部有问题,包括各种差错 1 缺少必需的选项(已废弃) 2 长度错误,总长度无效 1.3 不会产生 ICMPv4 报文的情况 源地址不是单个主机的数据报,即零地址、回环地址、广播地址或组播地址 目的地址是 IPv4 广播或组播地址 ICMPv4 差错报文 不是第一个分片的其他分片 作为链路层广播的数据报 2.

ICMP sockets (linux)

微笑、不失礼 提交于 2019-12-28 02:56:07
问题 Is it possible to use ICMP sockets under the IP protocol? Maybe something like: socket(PF_INET, <type>, IPPROTO_ICMP)? What should I put in the < type > field? I saw some examples using SOCK_RAW, but won't that prevent the OS from doing his job handling the IP protocol? And another thing. How can the OS know to which process he should send the ICMP datagrams, since there are no ports involved with the protocol? 回答1: Yes it is possible, since the ping command does ICMP. To find out the

Linux命令ping

寵の児 提交于 2019-12-27 17:43:51
原文 ping命令用来测试主机之间网络的连通性。执行ping指令会使用ICMP传输协议,发出要求回应的信息,若远端主机的网络功能没有问题,就会回应该信息,因而得知该主机运作正常。 语法 ping(选项)(参数) 选项 -d:使用Socket的SO_DEBUG功能; -c<完成次数>:设置完成要求回应的次数; -f:极限检测; -i<间隔秒数>:指定收发信息的间隔时间; -I<网络界面>:使用指定的网络界面送出数据包; -l<前置载入>:设置在送出要求信息之前,先行发出的数据包; -n:只输出数值; -p<范本样式>:设置填满数据包的范本样式; -q:不显示指令执行过程,开头和结尾的相关信息除外; -r:忽略普通的Routing Table,直接将数据包送到远端主机上; -R:记录路由过程; -s<数据包大小>:设置数据包的大小; -t<存活数值>:设置存活数值TTL的大小; -v:详细显示指令的执行过程。 ping 192.168.1.9 开始;ctrl + c 停止   ping命令通过ICMP(Internet控制消息协议)工作;ping可以用来测试本机与目标主机是否联通、联通速度如何、稳定性如何。 一、ping用法:   ping命令运行在命令提示符终端,用法为:“ping 参数 目标主机”。其中参数为零到多个,目标主机可以是IP或者域名。 1 2 3 4 Usage: