Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

指定网卡请求功能 #288

Open
LunacyZeus opened this issue May 26, 2021 · 4 comments
Open

指定网卡请求功能 #288

LunacyZeus opened this issue May 26, 2021 · 4 comments

Comments

@LunacyZeus
Copy link

curl可以使用interface参数指定网卡请求,当遇到多张网卡的时候想要指定一张网卡进行请求就需要用到了
golang我测试了一下也可以实现 希望作者能集成到库中
实现源码
https://github.com/hardPass/code_go_network/blob/master/Golang%20%E7%94%A8%E6%8C%87%E5%AE%9A%E7%BD%91%E5%8D%A1%E7%9A%84IP%E5%8F%91%E9%80%81HTTP%E8%AF%B7%E6%B1%82.go

@guonaihong
Copy link
Owner

ok, 最近的版本安排上.

guonaihong added a commit that referenced this issue Jun 4, 2021
@guonaihong
Copy link
Owner

这个功能是开发完, 比较头疼的是自测代码不好写.

@LunacyZeus
Copy link
Author

是的 我这里也在看看~不过我看的估计只有linux才可以吧
之前发的demo是绑定ip的办法 绑定ip好像可以支持windows
linux我最近找到一个类似curl的功能 curl http://httpbin.org/ip --interface 网卡名(ppp0 eth0)
大概差不多就是这样的功能
我看看能不能写个简单的demo出来

@guonaihong
Copy link
Owner

这个测试麻烦在于, 如果在内网, 指定url, 其实就不需要这个功能. 同网段通信, 目标ip 和网卡出口ip是一个网段的.所以只要指定url就不需要这个功能.

我想到一种测试方式, 在本机虚拟出两块网卡, 中间经过路由器跳到另一个网段的某台机器, 然后观察下源ip地址.

这块可能要看下iptables的一些用法.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants