linux - 如何通过虚拟接口(interface)发送请求

标签 linux networking

<分区>

我已经使用

创建了一个虚拟接口(interface)
ifconfig eth0:1 192.168.50.10 netmask 255.255.255.0 up

现在我使用 curl 通过虚拟接口(interface)向服务器发送请求:

curl --interface 192.168.50.10 http://192.168.50.1:8080/myhostedapp

这工作正常,我的应用程序将源 IP 显示为 192.168.50.10,但如果服务器位于不同的子网上,并且可以从物理接口(interface) (eth0) 访问,则连接超时。

所以这有效(通过物理接口(interface)): curl http://10.10.50.1:8080/myhostedapp

但这失败了: curl --interface 192.168.50.10 http://10.10.50.1:8080/myhostedapp.

为了 10.10.50.1 到达 192.168.50.10,我将它添加到路由表中。

我需要配置什么才能从 192.168.50.10 访问 10.10.50.1

最佳答案

你必须设置 iptunnel 你可以看到这个链接它会更清楚,当你添加路由时你添加了带有网关的路由。

https://unix.stackexchange.com/questions/44065/linux-networking-routing-to-virtual-ip-addresses-from-a-different-subnet

感谢和问候,
阿洛克塞克

关于linux - 如何通过虚拟接口(interface)发送请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19810280/

相关文章:

networking - 如何在没有端口映射的情况下将 docker 容器的 ip 和端口暴露给外部 docker 主机?

networking - Arduino 射频传感器网络

linux - cmake 停止使用 -pthread

服务器和客户端是否可以在同一个端口上发起通信并发送命令?

linux - 在 Linux 中监视文件系统更改的最佳方法

linux - 用于从 txt 文件中删除一行文本的 bash 脚本

Azure 网络 ActiveFTP 问题

unix - 为什么NFS默认使用UDP?

python - 在不使用数据库软件的情况下从表中获取项目列表

linux - 2 iptables 规则我不明白