iptables - administration tools for packet filtering and NAT

2023-05-16

2. iptables - administration tools for packet filtering and NAT

Linux Iptables Manual


	
      Incoming
       Traffic
          |
          |
          V
     +----------+
     |PREROUTING|
     +----------+
     |   raw    |  <--------------+
     |  mangle  |                 |
     |   nat    |                 |
     +----------+                 |
          |                       |
          |                       |
       Routing                    |
    +- Decision -+                |
    |            |                |
    |            |                |
    V            V                |
  Local        Remote             |
Destination   Destination         |
    |            |                |
    |            |                |
    V            V                |
+--------+  +---------+           |
| INPUT  |  | FORWARD |           |
+--------+  +---------+           |
| mangle |  | mangle  |           |
| filter |  | filter  |           |
+--------+  +---------+           |
    |            |                |
    |            |                |
    V            |                |
  Local          |                |
 Machine         |                |
    |            |                |
    |            |                |
    V            |                |
 Routing         |                |
 Decision        |                |
    |            |                |
    |            |                |
    V            |                |
+--------+       |                |
| OUTPUT |       |                |
+--------+       |                |
|  raw   |       |                |
| mangle |       |                |
|  nat   |       |                |
| filter |       |                |
+--------+       |                |
    |            |                |
    |      +-------------+        |
    |      | POSTROUTING |      Local
    +----> +-------------+ --> Traffic
           |   mangle    |
           |     nat     |
           +-------------+
                 |
                 |
                 V
              Outgoing
              Traffic
	
	  

2.1. Getting Started

Redhat / CentOS

You can check to see if iptables is installed on your system by:


[root@database ~]# rpm -q iptables
iptables-1.3.5-5.3.el5_4.1
		  

And to see if iptables is actually running, we can check that the iptables modules are loaded and use the -L switch to inspect the currently loaded rules:


[root@database ~]# lsmod | grep ip_tables
ip_tables              55201  2 iptable_nat,iptable_filter
x_tables               50505  6 ipt_MASQUERADE,iptable_nat,xt_state,ipt_REJECT,xt_tcpudp,ip_tables

		  

[root@database ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere            udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:bootps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             192.168.122.0/24    state RELATED,ESTABLISHED
ACCEPT     all  --  192.168.122.0/24     anywhere
ACCEPT     all  --  anywhere             anywhere
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

		  

If iptables is not running, you can enable it by running:


# system-config-securitylevel
		  

2.2. User-defined Chain

2.2.1. Chains List

列出规则链


 列出INPUT,OUTPUT,FORWARD规则
iptables -L

列出NAT规则
iptables -t nat -L

列出过滤规则
iptables -t filter -L
			  

2.2.2. Chains Refresh

刷新规则


/sbin/iptables -F
/sbin/iptables -F -t filter
/sbin/iptables -F -t nat
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
			  

2.2.3. Chains Admin

创建新链


				iptables -N netkiller
			  

删除新链


				# iptables -X netkiller
			  

2.3. Common Chains Filtering

2.3.1. INPUT Rule Chains

2.3.1.1. OpenSSH

# Accept tcp packets on destination port 22 (SSH)
 iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Accept tcp packets on destination port 22 (SSH) from private LAN
 iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 22 -j ACCEPT
			  
2.3.1.2. FTP

/sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 20 -j ACCEPT
			  
2.3.1.3. DNS

iptables -A INPUT -i eth0 -p tcp --dport 53   -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 53   -j ACCEPT
			  
2.3.1.4. WWW

# WWW
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# HTTPS
/sbin/iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Tomcat
/sbin/iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
			  
2.3.1.5. SOCKS5

/sbin/iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
			  
2.3.1.6. Mail Server

# SMTP
/sbin/iptables -A INPUT -p tcp --dport 25 -j ACCEPT
# SMTPS
/sbin/iptables -A INPUT -p tcp --dport 465 -j ACCEPT
# POP3
/sbin/iptables -A INPUT -p tcp --dport 110 -j ACCEPT
# POP3S
/sbin/iptables -A INPUT -p tcp --dport 995 -j ACCEPT
# IMAP
/sbin/iptables -A INPUT -p tcp --dport 143 -j ACCEPT
# IMAPS
/sbin/iptables -A INPUT -p tcp --dport 993 -j ACCEPT
			  
2.3.1.7. MySQL

/sbin/iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
			  
2.3.1.8. PostgreSQL

/sbin/iptables -A INPUT -p tcp --dport 5432 -j ACCEPT
			  
2.3.1.9. DHCP

iptables -A INPUT -p UDP -i eth0 --dport 67 -j ACCEPT
iptables -A INPUT -p UDP -i eth0 --dport 68 -j ACCEPT
			  
2.3.1.10. Samba

/sbin/iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 137 -j ACCEPT
iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 145 -j ACCEPT
iptables -A INPUT -p udp -s 192.168.0.0/24 --dport 138 -j ACCEPT
iptables -A INPUT -p udp -s 192.168.0.0/24 --dport 139 -j ACCEPT
			  
2.3.1.11. ICMP


accept_redirects
# echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
or
# sysctl net.ipv4.conf.all.accept_redirects="0"


使自己不能ping 通 127.0.0.1
iptables -A INPUT -s 127.0.0.1 -p icmp -j DROP

192.168.0.0/24 网段无法ping能本机
iptables -A INPUT -s 192.168.0.0/24 -p icmp -j DROP

禁所有机器
# iptables -A INPUT -s 0/0 -p icmp -j DROP

# ICMP(PING) 接受 ! echo-request
iptables -A INPUT -p icmp --icmp-type ! echo-request -j ACCEPT
			  
2.3.1.12. 禁止IP访问自己

$sudo iptables -A INPUT -d 192.168.0.253 -j DROP
			  
2.3.1.13. DENY

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -j DROP
			  

2.3.2. OUTPUT Rule Chains

2.3.2.1. outbound

# Open ports for outbound established connections
$IPT -A OUTPUT -p tcp -s $NET -d 0/0 --destination-port 1:65535 -j ACCEPT
$IPT -A OUTPUT -p udp -s $NET -d 0/0 --destination-port 1:65535 -j ACCEPT
			  
2.3.2.2. ICMP


本地不允许ping 192.168.0.0/24
iptables -A OUTPUT -s 192.168.0.0/24 -p icmp -j DROP

禁所本地ping任何机器
# iptables -A OUTPUT -s 0/0 -p icmp -j DROP

# ICMP(PING) 接受 ! echo-request
iptables -A OUTPUT -p icmp --icmp-type ! echo-request -j ACCEPT

2.3.2.3. 禁止自己访问某个IP

# iptables -A OUTPUT -d 192.168.0.253 -j DROP
iptables -A OUTPUT -p udp -j DROP
iptables -A OUTPUT -d 125.211.210.46 -j DROP
			  

2.3.3. Forward


iptables -A FORWARD -i eth1 -j ACCEPT
		  

# Network 1 forwarded outgoing client request to network 2
iptables -A FORWARD -i eth1 -p tcp -s 192.168.1.0/24 -d 192.168.2.0/24 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A FORWARD -o eth1 -p tcp -s 192.168.2.0/24 -d 192.168.1.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPT
		  
2.3.3.1. TCPMSS

iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
			  

2.3.4. Malicious Software and Spoofed IP Addresses


# The following rules drop all TCP traffic that attempts to use port 31337:
iptables -A OUTPUT -o eth0 -p tcp --dport 31337 --sport 31337 -j DROP
iptables -A FORWARD -o eth0 -p tcp --dport 31337 --sport 31337 -j DROP
		  

2.4. Interfaces


iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i ppp0 -j ACCEPT
		  

2.5. IP Addresses


# Accept packets from trusted IP addresses
 iptables -A INPUT -s 192.168.0.4 -j ACCEPT # change the IP address as appropriate

# Accept packets from trusted IP addresses
 iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT  # using standard slash notation
 iptables -A INPUT -s 192.168.0.0/255.255.255.0 -j ACCEPT # using a subnet mask


# Accept packets from trusted IP addresses
 iptables -A INPUT -s 192.168.0.4 -m mac --mac-source 00:50:8D:FD:E6:32 -j ACCEPT
		  

2.6. Ports and Protocols


# Accept tcp packets on destination port 6881 (bittorrent)
 iptables -A INPUT -p tcp --dport 6881 -j ACCEPT

# Accept tcp packets on destination ports 6881-6890
 iptables -A INPUT -p tcp --dport 6881:6890 -j ACCEPT
		  

2.7. IPTables and Connection Tracking


NEW — A packet requesting a new connection, such as an HTTP request.

ESTABLISHED — A packet that is part of an existing connection.

RELATED — A packet that is requesting a new connection but is part of an existing connection. For example, FTP uses port 21 to establish a connection, but data is transferred on a different port (typically port 20).

INVALID — A packet that is not part of any connections in the connection tracking table.


iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
		  

2.8. NAT

2.8.1. Redirect

重定向规则


端口重定向
# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 21 -j REDIRECT --to-port 2401

将80端口重定向到8080
# iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080
			  

端口转发


echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -d 192.168.3.9 -p tcp -m tcp --dport 1000 -j DNAT --to-destination 192.168.3.137:8080
iptables -t nat -A POSTROUTING -s 192.168.3.0/255.255.255.0 -d 192.168.3.137 -p tcp -m tcp --dport 8080 -j SNAT --to-source 192.168.3.9
			  

2.8.2. Postrouting and IP Masquerading


			
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -t nat -I POSTROUTING -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -j MASQUERADE -s 172.16.0.0/24 -d 0.0.0.0/0
sudo iptables -t nat -A POSTROUTING -j MASQUERADE -o eth1 -s 172.16.1.0/24 -d 0.0.0.0/0
sudo iptables -t nat -A POSTROUTING -j MASQUERADE -p tcp -o eth1 -s 172.16.1.0/24 -d 0.0.0.0/0
			
			  

2.8.3. Prerouting


iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 172.31.0.23:80
		  

If you have a default policy of DROP in your FORWARD chain, you must append a rule to forward all incoming HTTP requests so that destination NAT routing is possible. To do this, use the following command:


iptables -A FORWARD -i eth0 -p tcp --dport 80 -d 172.31.0.23 -j ACCEPT
		  

This rule forwards all incoming HTTP requests from the firewall to the intended destination; the Apache HTTP Server behind the firewall.

2.8.4. DNAT and SNAT


echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -d 202.103.96.10 -j DNAT --to-destination 192.168.0.10
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 202.96.244.56
		  

2.8.5. DMZ zone


#
# DMZ zone
#
$iptables -t nat -A PREROUTING -p TCP -m multiport -i eth0 --dport 22,25,113,80,8080 -j DNAT --to 10.0.0.10
$iptables -t nat -A PREROUTING -p UDP -i eth0 --dport 25 -j DNAT --to-destination 10.0.0.10
			  

DNAT ppp0/eth0


			
iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 80 -j DNAT --to-destination <web server ip>
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.0.4.2:80
			
			  

2.9. IPV6


		
[root@linux iptables]# modprobe ipv6
[root@linux iptables]# modprobe ip6_tables
[root@linux iptables]# [ ! -f /proc/net/ip6_tables_names ] && echo "Current kernel doesn't support? 'ip6tables' firewalling (IPv6)!"
[root@linux iptables]# ip6tables -A INPUT -i eth0 -p tcp -s 3ffe:ffff:100::1/128 --dport 22 -j ACCEPT
		
		  

2.10. iptables-xml - Convert iptables-save format to XML

2.11. Example

例 23.1.


/sbin/iptables -F
/sbin/iptables -F -t filter
/sbin/iptables -F -t nat
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT

-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

sysctl net.ipv4.ip_forward=1
			  

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iptables - administration tools for packet filtering and NAT 的相关文章

  • K8S iptables 与 pod 内容器的关系

    我已在容器中启用特权模式并向其添加规则 iptables N udp2rawDwrW 191630ce C0 iptables F udp2rawDwrW 191630ce C0 iptables I udp2rawDwrW 191630c
  • 如何阅读 FSM 图

    我如何获取该图并将其转换为可用的程序 我不太确定如何阅读该图 引导我完成它 也许会展示一个代码示例以及它与图表的关系 里面有文字的圆圈是州 文本描述了状态是什么 虚线箭头指向起始状态 传出箭头确定此状态可以更改的位置 箭头旁边是被线分为上半
  • TEE 之后如何处理镜像(重复)的 iptables 流量?

    我有一个关于使用 TEE 选项 iptables 流量进行镜像的问题 主要目标是将服务器 A 端口 1935 上服务的所有流量复制到服务器 B 上同一端口 端口 1935 上运行的相同服务 例如 如果我开始将视频流式传输到 192 168
  • 由于 IPTABLES 更改,SVN 无法工作

    由于我重新启动了安装了 svn 的 Ubuntu 服务器 因此我无法从笔记本电脑访问它 使用 svnX 当我尝试浏览我的曲目库时 出现错误 svn Can t connect to host xxx xxx Address already
  • 低功耗蓝牙 - 重复更新特征值

    关于电气工程 Stackexchange 的后续问题 https electronics stackexchange com questions 30964 improving throughput of a bluetooth low e
  • 即使我的电脑是这样,teamviewer 如何找到我的电脑?防火墙后面和防火墙没有配置?

    你用过teamviewer吗 我知道的漫画问题 谁不使用它 即使我位于路由器 防火墙 交换机和本地防火墙后面 您知道 teamviewer 如何建立连接吗 我试图想象远程机器和我的计算机之间的连接 远程计算机正在向我发送数据包 及其标头 例
  • NodeJS 服务器无法从外部访问

    我在Rackspace中部署了一个nodejs服务器 可以在内部访问 例如使用 curl http 127 0 0 1 8080 但是 即使我这样做 也无法从外部 互联网 访问它 iptables A OUTPUT p tcp dport
  • Spring 事务因 iptables 命令而挂起

    作为进程错误处理的一部分 我们尝试使用以下 iptables 命令禁用进程与数据库计算机侦听器端口之间的通信 iptables A INPUT p tcp destination port
  • 尝试使用 ServerManager 获取应用程序池时出现 COMException

    当我尝试使用以下代码从远程服务器获取 IIS 应用程序池列表时 List
  • 以管理员身份运行批处理文件 - Windows 7 - 从网络文件系统命令“运行方式”

    我需要设置程序安装程序的交付 该程序有一个program installer exe 和一个文件夹 我在创建安装程序时无法将其包含在安装程序中 因此 当用户需要安装该程序时 我通过邮件向他发送一个批处理文件 echo off if DEFI
  • Scapy:原始 ICMP 数据包没有回复

    我已经构建了一个数据包scapy a IP dst 192 168 0 1 proto 1 x08 x00 xf7 xff x00 x00 x00 x00 I run send a Wireshark 显示有来自 192 168 0 1 的
  • CouchDB 备份和克隆数据库

    我们正在寻找 CouchdDB 作为类似 CMS 的应用程序 围绕备份我们的生产数据库有哪些常见模式 最佳实践和工作流程建议 我对克隆数据库以用于开发和测试的过程特别感兴趣 仅从实时运行的实例下复制磁盘上的文件就足够了吗 您可以在两个实时运
  • 如何设置Robots.txt或Apache仅在特定时间允许爬虫?

    由于 24 小时内流量分布不均匀 我希望在高峰时段禁止爬虫 在非繁忙时段允许爬虫 有没有一种方法可以实现这一目标 编辑 感谢所有的好建议 这是我们找到的另一个解决方案 2bits com 有一篇关于设置 IPTables 防火墙以限制来自某
  • TFS 2017.3.1 合并集合 [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我们目前使用 TFS 2017 3 1 On Prem 我们有 1 个非常大的收藏和另一个较小的收藏 我们想将较小的收藏移至较大的收藏
  • Perl IPTables 模块安装错误

    我一直在尝试为 perl 安装 IPTables 模块http metacpan org pod IPTables IPv4 http metacpan org pod IPTables 3a 3aIPv4我在安装过程中遇到了错误 我尝试在
  • 如何检查 MySQL 和 Tomcat 是否正在运行?

    我创建了一个 Java 应用程序 该应用程序分为不同的子组件 每个子组件都在单独的 Tomcat 实例上运行 此外 某些组件通过 Hibernate 使用 MySQL 数据库 我现在正在创建一个管理控制台 在其中报告所有 Tomcat 实例
  • 如何以非root用户身份运行node.js?

    我正在运行一个 node js 服务器 它将服务端口 80 上的请求等 显然 这需要应用程序以 root 身份运行 在 Linux 上 正在看这个帖子 http syskall com dont run node dot js as roo
  • Docker容器内的动态监听端口

    我有一个应用程序 在使用其默认端口建立一些连接后 开始打开 侦听 新的随机端口来处理现有连接 然后删除它们 视频通话 它还在通信协议内交换其IP地址和端口 我能够解决IP地址问题 但仍然无法找到一种方法来动态告诉主机的IPTABLES在Do
  • 更新 Mac OS 10.7 的 grep

    我想将 Mac 上的 grep 更新到比 Mac OS 10 7 2 附带的 2 5 1 更新的版本 我的问题是 为 Mac 更新 grep 或任何类似程序 的最佳方法是什么 我可以使用 Fink 或 MacPorts 安装新版本并设置路径
  • Squid+iptables:如何允许https通过并绕过Squid?

    今天基本上是从 Squid 和 iptables 开始的 google 是你的朋友 这东西会害死我的 我在 Ubuntu 9 04 服务器上设置了 Squid3 作为透明代理 当我使用代理盒作为我的默认网关等时 它工作得很好 此设置的 ip

随机推荐

  • 基于导航网格的A星寻路(Navigation mesh)

    最近花了几个月的时间实现了导航网格寻路和导航网格自动生成 导航网格数据结构定义 由于数据之间有着层级关系 xff0c 所以采用XML进行定义 navmesh基本元素 xff1a 顶点 Verts 43 可走边 Edges 43 凸多边形 P
  • cmake 引入 动态库、静态库

    动态库 xff1a link directories PROJECT SOURCE DIR lib 添加动态连接库的路径 target link libraries project name lMNN 添加libMNN so 静态库 xff
  • 利用JSP内置对象Request和Application实现用户名密码登录注册进入首页显示

    学习目标 xff1a 实验名称 xff1a JSP内置对象目的 xff1a 掌握JSP页面的全部语法 能够编写基本的JSP网页 学习内容 xff1a 1 实验 地点 周三2单元 xff0c 10617综合一实验室 自带电脑 目的 掌握各种内
  • 【如何写CMake】一个解决方案,多个工程

    文章目录 代码参考 一个解决方案 xff0c 多个工程 xff0c 即多个exe dll lib等 代码 多加几个ADD EXECUTABLE即可 1 cmake verson xff0c 指定cmake版本 cmake minimum r
  • 指针、寄存器、位操作

    定义寄存器的绝对地址 xff0c 并转换为指针进行位操作 1 位操作示例一 define PERIPH BASE unsigned int 0x40000000 define APB2PERIPH BASE PERIPH BASE 43 0
  • 详解TCP连接的建立

    TCP首部格式 TCP报文段首部的前20个字节是固定的 xff0c 后面有4N字节是根据需要而增加的选项 xff0c 因此TCP报文段的最小长度为20字节 首部固定部分的各字段的意义如下 xff1a 1 源端口和目的端口 xff1a 加上I
  • printf打印函数的原理浅析

    printf的底层原理浅析 目录 printf的底层原理浅析前言函数变参格式解析一个简单的printf示例结语 补充 前言 最近在学习linux内核的时候用到了自定义实现的printf xff0c 学习了一下 xff0c 在此记录 xff0
  • 基于公开网站挖掘敏感信息的研究与分析- Fofa 搜索

    基于公开公开网站挖掘敏感信息的研究与分析 Fofa 搜索 一 引言 1 1项目概述 基于公开网站的敏感信息挖掘研究与分析 xff1a 针对目前网络安全整体的趋势我们从google等搜索引擎 Github等代码库 FOFA等空间搜索这三个方面
  • HTTP报文

    一 HTTP报文的结构 用于HTTP协议交互的信息 xff0c 称为HTTP报文 客户端的HTTP报文称为请求报文 xff0c 服务端的称为响应报文 HTTP报文结构如下图 xff1a 下面是请求报文的一个实例 xff1a 请求行 xff1
  • 用C++写一个UDP发送和接收程序

    发送程序Sender cpp include lt stdio h gt include lt string gt include lt iostream gt include lt winsock h gt using namespace
  • STM32自学笔记(五)串口通信

    xff08 想要深入理解就把前面的看下 xff0c 否则直接看使用总结即可 xff09 usart文件夹 usart 文件夹内包含了 usart c和usart h两个文件 这两个文件用于串口的初始化和中断接收 代码只针对了串口1 xff0
  • sockaddr_in详解

    struct sockaddr in short sin family Address family一般来说AF INET xff08 地址族 xff09 PF INET xff08 协议族 xff09 unsigned short sin
  • ubuntu下好用的TCP/UDP调试工具

    github官方链接 GitHub s kyo mNetAssist mNetAssist A UDP TCP Assistant 编译好的安装包 ubuntu下好用的TCP UDP调试工具 网络设备文档类资源 CSDN下载 1 解压dpk
  • Linux网络编程之connect函数分析

    在一个 CLIENT SERVER模型的网络应用中 xff0c 客户端的调用序列大致如下 xff1a socket gt connect gt recv send gt close 其中socket没有什么可疑问的 xff0c 主要是创建一
  • linux route 命令

    显示现在所有路由 route n root 64 Ubuntu route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10
  • 大量LAST_ACK 分析过程

    记录一下自己的思想过程 现象 在netstat的时候发现大量处于LAST ACK状态的TCP连接 xff0c 达到在ESTABLISHED状态的90 以上 root 64 ccsafe netstat ant fgrep 34 34 cut
  • const 与重载

    const到底是不是一个重载的参考对象 xff0c 请看下面的例子 class A public void f int i std cout lt lt 34 1 34 函数1 void f int i const std cout lt
  • 指向成员函数的指针

    指向成员函数的指针 取一个非静态成员函数的地址 xff0c 如果该函数是nonvirtual xff0c 则得到的结果是它在内存中真正的地址 然而这个值也不是完全的 xff0c 它也需要被绑定于某个class object的地址上 xff0
  • rviz 远程显示及控制移动机器人的导航

    环境 xff1a xff08 1 xff09 虚拟机本地端IP 192 168 10 30 xff08 虚拟机需要通过桥接的形式与PC本地机连接 xff0c PC 机IP 192 168 10 21 xff09 xff08 2 xff09
  • iptables - administration tools for packet filtering and NAT

    2 iptables administration tools for packet filtering and NAT Linux Iptables Manual Incoming Traffic V 43 43 PREROUTING 4