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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-12-9 15:05:07 | 显示全部楼层 |阅读模式
# curl --interface ens7 www.baidu.com- g% Q# c5 [8 L% V0 g
<!DOCTYPE html>: T2 j# _7 D) z& ?$ Q
<!--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>
1 }1 i1 J* ~/ U3 d+ ^8 F9 \
. g" r5 I! w+ ?6 q& `: t' [& a: H. _* w7 P( u1 F! X. p
说明网卡ens7 可以访问外网。

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:06:14 | 显示全部楼层
测试无误。3 H7 }; S) [* Z7 j/ g
+ l# e0 b( U- p/ u
curl --interface usb0 网址 -X POST -d "数据"( S* I. P3 d1 u  O; `: p
--interface 指定网卡
  J/ X0 U1 m9 E8 x- y: {-X是POST还是GET
$ @; m, |8 Z, Q: {% C# h-d body数据

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:09:57 | 显示全部楼层
curl --interface eth0 网址
7 k# q4 x; O% O. y. j+ Lwget --bind-address=127.0.0.1 网址1 S  Q; \, U( N* V2 A: B) D$ v

" z, n9 V! Y6 q0 |# Ycurl -v方式获取端口是否正常通信3 ], H8 }) Q* O/ U* }
curl -v 10.16.68.32:229 T) w" a1 |- G( ]6 p1 L1 Q
* Rebuilt URL to: 10.16.68.32:22/
$ w) T' c' C5 Z" p# N" W. D*   Trying 10.16.68.32...
0 z+ X- n  }/ z0 w* _* TCP_NODELAY set8 ?* V8 _: F- R, P  n$ i
* Connected to 10.16.68.32 (10.16.68.32) port 22 (#0)
; J8 e; c5 ~$ G. c: z9 T> GET / HTTP/1.16 ]4 R5 i# N8 e! h2 z$ d* M
> Host: 10.16.68.32:22
! S9 T9 @1 ^! {+ I- p2 `; e) ~> User-Agent: curl/7.61.1
+ s0 ~8 P, q4 L; K4 S4 [> Accept: */*
3 u! A: o9 D% s! m. y>
4 K# \) D. D0 ~6 r9 o7 X) t, H5 ISSH-2.0-OpenSSH_8.0+ M' ~' Q  n" `; x' z
Invalid SSH identification string.
  }' e' N# g' B9 h; d1 i* Recv failure: Connection reset by peer
. U( e9 s3 z# W* R& U( J! p* Closing connection 0
0 _) l* q, F+ e0 o* ^0 kcurl: (56) Recv failure: Connection reset by peer

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-12-9 15:16:43 | 显示全部楼层
curl 加上--interface 参数,以及-v参数 达到预想结果。% Q: O( u5 k* L4 c# S/ L# e

/ L+ n- u; q2 K; d# R8 hcurl --interface ens7 -v 10.16.68.5:5901
6 q% |" y4 l/ t" Y+ a8 Y' ~" ]. [" k+ b
* Rebuilt URL to: 10.16.68.5:5901/
/ q4 p' x( x' ^$ @( S; i*   Trying 10.16.68.5...+ r* ]+ d( p+ S2 n, x: c
* TCP_NODELAY set
3 X2 i7 `7 P  C" k* Connected to 10.16.68.5 (10.16.68.5) port 5901 (#0)
  r/ a$ Y5 d3 H1 p0 F: Z* e> GET / HTTP/1.1/ U" I" \- }4 K
> Host: 10.16.68.5:5901! M# H: L$ V8 ]8 w% F6 z# T, P
> User-Agent: curl/7.61.1+ ~" T$ X7 I% a9 U3 s: H
> Accept: */*
% L  L4 V0 \' I8 U' N9 h( J0 ^& }> # G8 H% d( [0 e/ k4 Z0 C8 s
RFB 003.008
( i% \! g* k" w* Closing connection 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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