易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 27|回复: 3
收起左侧

curl 指定网卡访问业务 curl --interface 网卡

[复制链接]
发表于 2024-12-9 15:05:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
# curl --interface ens7 www.baidu.com5 H/ u  {$ k6 |: U
<!DOCTYPE html>
. C# J0 T/ P0 @; Y# T5 G/ Z<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>使用百度前必读</a>  <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号  <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
: k/ J2 C9 O0 e- l* V& g9 D. A/ t5 G9 R5 g& f' a; J6 i
7 N, m' w9 H- r: X( w" K% Z% }
说明网卡ens7 可以访问外网。
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。& R) p: B+ s6 {$ E# o& t
" F% R. `% C' z  S
curl --interface usb0 网址 -X POST -d "数据"
: j5 {3 m4 @; V--interface 指定网卡
7 t7 O( E. _/ g# [# z. [0 I-X是POST还是GET$ V$ i. Z: B7 }) L
-d body数据
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址6 {( D& w! ^0 S' ]& V5 t; }; o
wget --bind-address=127.0.0.1 网址% h& Z* M. z+ I# Y! P$ l" m' U0 B

0 M/ J* p( r+ O% O7 t: I3 vcurl -v方式获取端口是否正常通信+ ?$ x+ \8 `; j
curl -v 10.16.68.32:22
# X8 Z& j' t* X* Rebuilt URL to: 10.16.68.32:22/
$ ]% S  C' `& k*   Trying 10.16.68.32...
! d* I3 E9 B8 p# i# n3 _* TCP_NODELAY set4 G9 W! T4 O6 H
* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)1 S$ g, G6 O# w9 B* N
> GET / HTTP/1.1  R. L6 h- E$ a) r9 W; u
> Host: 10.16.68.32:228 Q2 \; Y7 ?% \& B
> User-Agent: curl/7.61.1
( Q5 ?4 y* v: z: U' y6 P> Accept: */*3 ?+ f5 R7 v. y/ [" n1 b
>
/ Q; P- @& z) a7 H- l  @SSH-2.0-OpenSSH_8.0
# T% \7 Z+ }( c2 x  [4 R7 e' jInvalid SSH identification string.
2 g+ ~3 |* Y" A8 f0 Q  J* Recv failure: Connection reset by peer
2 {  i, S- h' [& K. g* Closing connection 0) W  G1 o) W6 a8 Z. i
curl: (56) Recv failure: Connection reset by peer
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。
6 \7 N0 ^) m6 d# v; |+ r* l. S2 A/ U& l9 j3 u, Z3 `
curl --interface ens7 -v 10.16.68.5:59019 X; ^7 B+ X1 T4 D0 H4 H+ }
+ P: {7 o, z9 ?  R& T# E" t
* Rebuilt URL to: 10.16.68.5:5901/
8 i& G$ ^( z3 x4 U; V5 Q0 h*   Trying 10.16.68.5...+ z" c. Z: a6 c
* TCP_NODELAY set
  h! {$ x( E; B& ~( P7 M$ X* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0)( ?5 u6 j/ d: U& q% m/ T" Q# k# U3 G
> GET / HTTP/1.1
6 i- s/ S; q; D, X, g5 d> Host: 10.16.68.5:5901
+ i! C. L6 V0 V0 x> User-Agent: curl/7.61.1
6 T6 j7 s! x* a) _6 Z> Accept: */*5 w7 S7 S# p, L: W
> , v. ]5 a( G8 a' J  j, b2 n7 A
RFB 003.008
% m1 X, C1 Y5 g+ ?5 C+ ]9 E4 j* Closing connection 0
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:29 , Processed in 0.047270 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表