易陆发现互联网技术论坛

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

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

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

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

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

x
# curl --interface ens7 www.baidu.com8 @+ I; S2 ], j% U, k5 A/ S
<!DOCTYPE html>
  [1 O( n+ f: r! D<!--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' i% Q  Z% z( W* d0 l5 m+ A" |% ^2 M6 k9 j! i6 X1 l% S

6 f& |, B( `  \$ {& b说明网卡ens7 可以访问外网。
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。
0 M( z0 Z: _3 T2 v% d3 s3 Z0 a3 G( b
curl --interface usb0 网址 -X POST -d "数据"9 @0 w/ t+ i/ \, M$ ^3 H
--interface 指定网卡9 J! a' m6 B& F0 C# U
-X是POST还是GET7 F& X  y9 Z8 D2 g) P
-d body数据
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址
" {+ W4 X( e/ E/ l- }wget --bind-address=127.0.0.1 网址
1 J# c5 Y/ }9 L
# a! {& s% M2 M6 Fcurl -v方式获取端口是否正常通信! S  i" f# U5 ]& i
curl -v 10.16.68.32:22
% o. {7 Z# s) p" F* `! H. ?. R6 L* Rebuilt URL to: 10.16.68.32:22/" W$ j5 P4 }6 [0 h" z2 {
*   Trying 10.16.68.32...
  F  i+ M" R2 K6 J* TCP_NODELAY set
( w8 [' e, y2 i+ [. O" w' K* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)
! T# K+ n2 _) ~: ?: e+ l* V0 _> GET / HTTP/1.1- x9 M: ?& p; h9 V. _7 C5 t, U# S
> Host: 10.16.68.32:22
4 L5 M  s0 ]& W+ V> User-Agent: curl/7.61.12 G' X9 j+ B7 G, U
> Accept: */*0 R3 ]1 z  O% T' U* C
>
( i/ p8 _7 ^3 q8 M) b. A* XSSH-2.0-OpenSSH_8.0
, V. Q0 a  g( f# m& XInvalid SSH identification string.0 F" h  h  m; @6 ~
* Recv failure: Connection reset by peer
4 c0 F  _: i1 ]1 ^# s, ]8 v& ?* Closing connection 0+ h) d. E# y. U6 Z6 P* B6 o
curl: (56) Recv failure: Connection reset by peer
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。) I8 z" S2 k" C$ m4 T" ]! N
. ^8 r& X8 n' |# Z) D' b
curl --interface ens7 -v 10.16.68.5:5901
$ O$ B+ i1 H; L9 Y& O% \% Y  ?0 {! U& v& P" p$ V
* Rebuilt URL to: 10.16.68.5:5901/6 z$ n- n* K- T* \& d0 f3 T
*   Trying 10.16.68.5...
) v4 h$ s* c) T3 j1 Z8 q2 U* TCP_NODELAY set+ y8 {# j3 ~$ y1 r% y; }2 |$ r/ {. v
* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0)
) P+ N" ?- j+ g: {" X) Y' |> GET / HTTP/1.18 P- w2 ~0 G# v- R8 Q
> Host: 10.16.68.5:5901
! B* F6 p* Q( h: w  T6 n; ]5 L> User-Agent: curl/7.61.1) q# }' ^6 C" Z( A9 A5 [
> Accept: */*2 B. ?% W2 v" |! f0 N6 @5 E
>
3 p8 }( `5 s0 nRFB 003.008
  J' W! u; H1 |, {! C* Closing connection 0
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

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

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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