在Linux上运行lwIP Echo服务器的网络配置问题

在Linux上运行lwIP Echo服务器的网络配置问题,linux,ubuntu,lwip,Linux,Ubuntu,Lwip,我对使用编程感兴趣。为了进行实验,我一直在尝试运行示例应用程序中包含的。但是,我在设置与服务器通信的内部网络配置时遇到困难,我想找出我做错了什么。这是我到目前为止所做的 首先,我使用sudo成功地启动了echo服务器,并将其设置为在172.16.0.2上侦听,以172.16.0.1作为网关: >>sudo ./echop -i 172.16.0.2 -m 255.255.0.0 -g 172.16.0.1 [sudo] password for user: Host at 172.

我对使用编程感兴趣。为了进行实验,我一直在尝试运行示例应用程序中包含的。但是,我在设置与服务器通信的内部网络配置时遇到困难,我想找出我做错了什么。这是我到目前为止所做的

首先,我使用sudo成功地启动了echo服务器,并将其设置为在172.16.0.2上侦听,以172.16.0.1作为网关:

>>sudo ./echop -i 172.16.0.2 -m 255.255.0.0 -g 172.16.0.1
[sudo] password for user: 
Host at 172.16.0.2 mask 255.255.0.0 gateway 172.16.0.1
TCP/IP initialized.
SNMP private MIB start, detecting sensors.
Applications started.
程序成功启用
tap0
界面并启动网关:

>>ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe4c:f329  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:4c:f3:29  txqueuelen 1000  (Ethernet)
        RX packets 10860  bytes 10827195 (10.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8571  bytes 904790 (904.7 KB)
        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 1  (Local Loopback)
        RX packets 811  bytes 93113 (93.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 811  bytes 93113 (93.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.0.1  netmask 255.255.0.0  broadcast 172.16.255.255
        inet6 fe80::49f:4fff:fe82:d8fb  prefixlen 64  scopeid 0x20<link>
        ether 06:9f:4f:82:d8:fb  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 129  bytes 14904 (14.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
>>ping -c 5 172.16.0.1
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=64 time=0.076 ms
64 bytes from 172.16.0.1: icmp_seq=3 ttl=64 time=0.097 ms
64 bytes from 172.16.0.1: icmp_seq=4 ttl=64 time=0.037 ms
64 bytes from 172.16.0.1: icmp_seq=5 ttl=64 time=0.039 ms
--- 172.16.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4086ms
rtt min/avg/max/mdev = 0.028/0.055/0.097/0.027 ms
但是,如果我试图到达实际的echo服务器,则找不到路由:

>>ping -c 5 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.
From 172.16.0.1 icmp_seq=1 Destination Host Unreachable
From 172.16.0.1 icmp_seq=2 Destination Host Unreachable
From 172.16.0.1 icmp_seq=3 Destination Host Unreachable
From 172.16.0.1 icmp_seq=4 Destination Host Unreachable
From 172.16.0.1 icmp_seq=5 Destination Host Unreachable
如果我列出了当前的路线,看起来好像已经添加了路线:

>>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 tap0
172.16.0.0      0.0.0.0         255.255.0.0     U     0      0        0 tap0
为确保安全,我已尝试向echo服务器添加显式路由,但仍然找不到该路由:

>>sudo route add 172.16.0.2 dev tap0 gw 172.16.0.1
>>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 tap0
172.16.0.0      0.0.0.0         255.255.0.0     U     0      0        0 tap0
172.16.0.2      172.16.0.1      255.255.255.255 UGH   0      0        0 tap0

>>ping -c 5 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.
From 172.16.0.1 icmp_seq=1 Destination Host Unreachable
From 172.16.0.1 icmp_seq=2 Destination Host Unreachable
From 172.16.0.1 icmp_seq=3 Destination Host Unreachable
From 172.16.0.1 icmp_seq=4 Destination Host Unreachable
From 172.16.0.1 icmp_seq=5 Destination Host Unreachable

--- 172.16.0.2 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4094ms
pipe 4
我希望获得有关配置接口/路由的帮助,以便我可以试验在端口7上配置的lwIP(1.30)echo服务器。使用1.30版,就像我在旧设备上使用它一样

操作系统信息:

>>uname -a
Linux ReSyst 4.8.0-59-generic #64-Ubuntu SMP Thu Jun 29 19:38:34 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
谢谢