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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-12-9 15:05:07 | 显示全部楼层 |阅读模式
# curl --interface ens7 www.baidu.com3 ^! Y- j  M9 p* E3 j8 z, z
<!DOCTYPE html>" A. _3 u" o( i8 Q4 ]- U, |; h
<!--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>
' d2 [. p, U& H6 x3 E% }" B9 i3 G/ [; r5 a5 e# r6 w  i
& R* L- w* i, C5 {$ B; u6 I
说明网卡ens7 可以访问外网。

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。( L- a$ Y: N6 s* Q! Y4 z0 z
! G8 U% v  ]" O0 y* y; c, X0 _
curl --interface usb0 网址 -X POST -d "数据"4 i) K4 ~8 t' Z3 ?$ m1 m2 q
--interface 指定网卡3 A9 f: H4 U2 w9 }8 E- t
-X是POST还是GET5 a9 V/ M( a" W5 t# @
-d body数据

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址
2 r! c5 @' |+ t6 v* a; m+ G; bwget --bind-address=127.0.0.1 网址8 d! |* q, k- z) ^5 b% Q/ G* [
' y) |$ j+ c5 u8 p/ V9 L
curl -v方式获取端口是否正常通信! T+ e/ s$ P' y, Y9 r6 |; V
curl -v 10.16.68.32:22
# \4 ]4 {* J9 U& U0 S* Rebuilt URL to: 10.16.68.32:22/8 o( G: m$ ^2 P- |* t
*   Trying 10.16.68.32...0 j/ `" F% N. Z) h% ?
* TCP_NODELAY set
1 W! U8 P% q, L# D* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)
4 x6 Z7 q8 ^4 d. n> GET / HTTP/1.1. y, _- }, i4 I
> Host: 10.16.68.32:22
7 u% }5 j3 G! {0 B, h1 _: d5 z> User-Agent: curl/7.61.1
- t5 E, p% E  g; v> Accept: */*: i& W. s8 }/ c* `5 m: d
> ( o) b, U2 b$ S; D, B
SSH-2.0-OpenSSH_8.0
/ H' Q! }6 _# Y( Z& LInvalid SSH identification string.. A1 S6 M9 O0 x: `: I
* Recv failure: Connection reset by peer3 H8 Q( ~% l1 z" C
* Closing connection 0
/ n* @/ i9 M. L% ycurl: (56) Recv failure: Connection reset by peer

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。
1 t6 y; d7 a2 Y( A( u* N' v  D+ x9 z! C! e; E) I
curl --interface ens7 -v 10.16.68.5:5901# y+ M6 b  }- \- {

0 F, x$ u3 {( {: A* Rebuilt URL to: 10.16.68.5:5901/$ H% e$ b7 q2 {) B- a3 A! x
*   Trying 10.16.68.5...
5 w( f3 l# T, Z* TCP_NODELAY set; g5 _' A$ J; i- M- J* ]4 I
* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0), b9 V; d# D! O8 P* V2 f
> GET / HTTP/1.1
1 w4 e7 g; m! t' d9 e' ^8 C6 G" `> Host: 10.16.68.5:5901: j% ~& A4 F8 i! O6 j6 k
> User-Agent: curl/7.61.1. s$ n5 V7 Z2 i
> Accept: */*1 z/ ~$ ?+ ~  F& r$ V( D
> , r4 s0 l/ b4 N; @$ w. t
RFB 003.008
( D. h2 S! i9 p: e: G- E, N* Closing connection 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 01:48 , Processed in 0.014229 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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