0%

IPIP隧道

IPIP

scapy 构建 IPIP 包

tcpdump -i ens160 -nn -v ‘ip proto 4’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 外层IP头
outer_ip = IP(src="192.168.1.1", dst="192.168.1.2", proto=4) # proto=4表示IPIP

# 内层IP头
inner_ip = IP(src="10.0.0.1", dst="10.0.0.2")

# 内层负载数据
payload = "This is the payload"

# 组合成IPIP包
ipip_packet = outer_ip/inner_ip/payload

# 发送数据包
send(ipip_packet)


sendp(Ether(src="00:0c:29:4e:e5:7b", dst="00:0c:29:4e:e5:7a")/IP(src="192.168.1.1", dst="172.16.19.137", proto=4)/IP(src="10.0.0.1", dst="10.0.0.2")/"This is the payload")

IPv6 隧道

加载 ip6_tunnel 模块

1
modprobe ip6_tunnel

加载 ip6_tunnel 模块后,Linux 内核会自动创建一个默认的 IPv6 隧道接口 ip6tnl0

1
2
root@ubuntu2404:~# ip -6 tunnel show
ip6tnl0: ipv6/ipv6 remote :: local :: encaplimit 0 hoplimit inherit tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000)
1
2
3
ip -6 tunnel change ip6tnl0 mode ip6ip6

ip link set ip6tnl0 up