找回密码
 注册
查看: 38|回复: 3

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-12-9 15:05:07 | 显示全部楼层 |阅读模式
# curl --interface ens7 www.baidu.com9 e# D! N6 d9 q" G/ ?" V6 Q
<!DOCTYPE html>
+ N2 c# @0 T/ E<!--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>; r* r$ c. m; L6 z- T. P" R5 m
: V. C, Q8 C- Z( Q5 ?. o4 l$ u
: Q5 d& u' O' A: ]; x/ w
说明网卡ens7 可以访问外网。

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。
' ?1 O; Z2 X. h/ s( W3 R  ]- g" Q8 F0 E
curl --interface usb0 网址 -X POST -d "数据"
" \! Y+ \# H6 N" i--interface 指定网卡
6 r6 Z" M. ~6 u* v9 G0 f% g& X: W-X是POST还是GET
% g5 d& ]* z6 Y+ r& W: i-d body数据

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址
- B4 e( N2 q5 @1 o7 a* r8 t5 Twget --bind-address=127.0.0.1 网址
3 L; e- K$ }! K& X$ M/ j
1 [4 f/ F% E. k) N- b! p7 _curl -v方式获取端口是否正常通信9 C% l6 \( X8 v3 T
curl -v 10.16.68.32:22
4 Q+ k$ l  I  S7 m; J* Rebuilt URL to: 10.16.68.32:22/
; V- C: o3 M) c; n4 V6 i*   Trying 10.16.68.32...2 m6 I5 U. i; y! {, v7 |  a
* TCP_NODELAY set2 ?  r1 v/ G/ @
* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)) h0 }5 o6 z+ u9 h6 n) b" y* F
> GET / HTTP/1.1+ }: U" d% ?6 P- [& d; y
> Host: 10.16.68.32:22
  c: p' S) G) w3 F3 j% r. F> User-Agent: curl/7.61.17 r! {* h6 q) V$ G
> Accept: */*
! t6 t# _) q! t) c6 Z3 i. n; D* v5 F>
, n+ g, ]9 I! nSSH-2.0-OpenSSH_8.0
) `: w' a! N4 H, sInvalid SSH identification string.( x5 @& x" C+ s# z* w
* Recv failure: Connection reset by peer3 ]6 m" n. y, [! p0 J- z! ^
* Closing connection 0
: I; M4 R; |* k2 a/ O- mcurl: (56) Recv failure: Connection reset by peer

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。0 e+ ~3 J  s7 Z4 h6 l

$ ?- z5 n4 e9 W; v8 tcurl --interface ens7 -v 10.16.68.5:5901
8 ]+ q9 Z. m1 d& q4 @3 O! K! O2 c: I- B* X* Z$ Y
* Rebuilt URL to: 10.16.68.5:5901/
% Q. ?: H: A5 {* }+ [*   Trying 10.16.68.5...& _' r( a+ m  {5 w; U' H
* TCP_NODELAY set
: v1 x$ S, V8 I* r3 B8 H* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0)
% j2 ?+ U. I8 a> GET / HTTP/1.1. _5 @4 T9 V- Q# A9 Y9 \. F
> Host: 10.16.68.5:59010 N; F9 X* L( b( V( E
> User-Agent: curl/7.61.1
) V4 l# Z* B* M5 b. h% j> Accept: */*
: s' G! Z6 S& T3 C5 ^# A# ?> ( L% `! p! h+ b' v# {
RFB 003.008" I: J4 |. d+ E) p! [! ^
* Closing connection 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:45 , Processed in 0.023989 second(s), 21 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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