Я создал интерфейс tun из программы C. Теперь я хочу отправлять tcp-пакеты из этого интерфейса. Но у меня ошибка типа No route to host
на этом шаге.
Действия по воспроизведению:-
ip addr add dev tunchick4 192.168.43.55/24
ip link set up dev tunchick4
Результаты для некоторых команд: -
$ ifconfig
eno1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 10:62:e5:c8:fa:28 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4519 bytes 1183812 (1.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4519 bytes 1183812 (1.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tunchick4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.43.55 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::e4e7:1cff:fefb:5218 prefixlen 64 scopeid 0x20<link>
ether e6:e7:1c:fb:52:18 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.43.229 netmask 255.255.255.0 broadcast 192.168.43.255
ether 74:40:bb:30:cc:63 txqueuelen 1000 (Ethernet)
RX packets 30957 bytes 26107275 (24.8 MiB)
RX errors 0 dropped 5 overruns 0 frame 0
TX packets 28414 bytes 7927398 (7.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ping -I tunchick4 192.168.43.229
PING 192.168.43.229 (192.168.43.229) from 192.168.43.55 tunchick4: 56(84) bytes of data.
^C
--- 192.168.43.229 ping statistics ---
21 packets transmitted, 0 received, 100% packet loss, time 20256ms
$ ping -I wlo1 192.168.43.55
PING 192.168.43.55 (192.168.43.55) from 192.168.43.229 wlo1: 56(84) bytes of data.
^C
--- 192.168.43.55 ping statistics ---
15 packets transmitted, 0 received, 100% packet loss, time 14188ms
$ curl --interface tunchick4 http://192.168.43.229:8000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Directory listing for /</title>
</head>
<body>
<h1>Directory listing for /</h1>
<hr>
<ul>
<li><a href="index.php">index.php</a></li>
</ul>
<hr>
</body>
</html>
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 600 0 0 wlo1
192.168.43.0 0.0.0.0 255.255.255.0 U 600 0 0 wlo1