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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-12-9 15:05:07 | 显示全部楼层 |阅读模式
# curl --interface ens7 www.baidu.com0 l8 D. k1 j- t; Q+ H7 ?+ {' o5 g( C
<!DOCTYPE html>+ B# v; l; F) ]) n9 l; B3 v5 p8 U
<!--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>5 S' U3 x% ^" s$ |4 I+ K

, o& ?  L* F+ L  B! C- o
! y( l+ _8 ?: `1 |' ~+ q# ~0 K; c' v说明网卡ens7 可以访问外网。

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。
! b3 Y. p) e. }! g( l; k: p) H5 p1 X, K
curl --interface usb0 网址 -X POST -d "数据"
1 ~) Q- O' x3 z/ R, `( Q9 \--interface 指定网卡4 W% F4 i8 d% e7 y, E
-X是POST还是GET
  b2 u9 W) N0 S" |-d body数据

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址
# ]$ X( M+ _# J1 X, Z; e! @wget --bind-address=127.0.0.1 网址
% ?% J' l2 N7 A/ L! S6 x& V, i" j( E# B/ F/ I, Q) r) h
curl -v方式获取端口是否正常通信0 T: V5 H6 d. P* U6 O& _
curl -v 10.16.68.32:22+ t. E: s9 e; t# }! B1 ?
* Rebuilt URL to: 10.16.68.32:22/
0 L4 M1 N7 X, O0 t; U*   Trying 10.16.68.32...2 ?6 r) ^6 b5 c' O7 h/ D1 ~; `
* TCP_NODELAY set
& ~; Y8 P2 |' ^4 F9 N6 ~. @# G: Z) {* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)
) A: N$ [! w3 r" V8 O  }  i7 C> GET / HTTP/1.13 g' }3 r* e  e# y
> Host: 10.16.68.32:22
3 p2 D+ N$ M, I. K, _* U2 S0 X7 R> User-Agent: curl/7.61.17 {2 L- b: D8 @' X9 z6 L
> Accept: */*
1 C- R5 @- [9 I( e8 y> # Q5 t: \# O/ e; L6 m4 A( @$ ]
SSH-2.0-OpenSSH_8.0  a  |# ~6 u# s/ B7 P3 I# G
Invalid SSH identification string.0 \& }4 E; z# h3 A: x
* Recv failure: Connection reset by peer
0 m( O$ t" i! k2 _" y. @* Closing connection 0
! e2 \. O  k6 T- t$ \' j( jcurl: (56) Recv failure: Connection reset by peer

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。" G6 \( Y# M3 Q# _: V# [- E

7 j$ I0 o; {9 U: Lcurl --interface ens7 -v 10.16.68.5:5901( j1 p" W3 Z) p0 i: k& Z& x

7 }  J; B% S& x5 Q; K) s7 A- s/ g4 I$ k* Rebuilt URL to: 10.16.68.5:5901/
: h0 B7 j1 s1 z  P*   Trying 10.16.68.5...
7 j, K- c9 j( b: d$ u* TCP_NODELAY set
6 B$ \0 j" ^0 }, X7 n, G; T* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0)
$ a, A1 z$ g3 H+ i6 u+ q1 a2 Y> GET / HTTP/1.1- u6 J- c2 d, c
> Host: 10.16.68.5:5901; P: J( U1 K% u5 N) f. O
> User-Agent: curl/7.61.1
8 W% _# i- {' a7 t$ o* L% Q> Accept: */*
4 B( g. x1 R5 q! e: v> $ I$ r- U7 C9 Z
RFB 003.008
& C9 y0 [) Y2 Y* Closing connection 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 00:41 , Processed in 0.017427 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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