IT/Linux

wget 출발지 IP 변경

착한아줌마 2023. 2. 17. 12:43
반응형

 

 

 

 

이번엔 리눅스 기본 명령어 wget에서 출발지 IP를 변경하는 경우에 대해서 써본다.

 

 

 

일단 wget이 뭐하는 명령어인지 모를 수 있으니 간단하게

 

 

GNU Wget (간단히 Wget, 이전 이름: Geturl)는 웹 서버로부터 콘텐츠를 가져오는 컴퓨터 프로그램으로, GNU 프로젝트의 일부이다. 이 프로그램의 이름은 월드 와이드 웹과 get에서 가져온 것이다. HTTP, HTTPS, FTP 프로토콜을 통해 내려받기를 지원한다.
 

- wiki백과

 

 

실제로 다운로드가 필요한 경우에 쓰거나 테스트를 목적으로 간단하게 웹페이지를 떙겨오는 경우에 많이 쓰인다.

 

 

 


 

 

 

이제 wget 명령어의 출발지 IP를 변경하는 방법을 알아보자

 

 

 

우선 장비에서 가지고 있는 IP다.

 

세컨드리 IP로 13.13.13.13과 12를 생성해놓았다.

 

# ifconfig

 

14.14.14.10 웹 서버의 index.html 파일을 땡겨오는 테스트를 한다고 가정하자

 

이 경우에 별다른 조건이 없다면 enp1s0f0의 13.13.13.13 ip를 달고 파일을 가지고 온다.

 

# wget http://14.14.14.10

 

 

 

 

 

그치만 --bind-address 옵션을 사용하면 출발지를 특정 지을 수 있다.

 

아래와 같이 13.13.13.12와 13.13.13.13으로 번갈아 가면서 요청하는 모습을 확인할 수 있다.

 

# wget --bind-address=13.13.13.12 http://14.14.14.10

# wget --bind-address=13.13.13.13 http://14.14.14.10

 

 

 

아래는 명령어를 사용했을 때 실제로 출발지 IP가 바뀌는지를 확인한 tcpdump 내용이다.

 

[root@localhost ~]# tcpdump -ne -i enp1s0f0 not vrrp and not arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp1s0f0, link-type EN10MB (Ethernet), capture size 262144 bytes
15:59:20.047395 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 74: 13.13.13.12.36439 > 14.14.14.10.http: Flags [S], seq 1579464447, win 29200, options [mss 1460,sackOK,TS val 776021202 ecr 0,nop,wscale 7], length 0
15:59:20.048020 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 74: 14.14.14.10.http > 13.13.13.12.36439: Flags [S.], seq 1315893687, ack 1579464448, win 14480, options [mss 1460,sackOK,TS val 775995607 ecr 776021202,nop,wscale 7], length 0
15:59:20.048037 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.12.36439 > 14.14.14.10.http: Flags [.], ack 1, win 229, options [nop,nop,TS val 776021203 ecr 775995607], length 0
15:59:20.048150 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 175: 13.13.13.12.36439 > 14.14.14.10.http: Flags [P.], seq 1:110, ack 1, win 229, options [nop,nop,TS val 776021203 ecr 775995607], length 109: HTTP: GET / HTTP/1.1
15:59:20.049041 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.12.36439: Flags [.], ack 110, win 114, options [nop,nop,TS val 775995608 ecr 776021203], length 0
15:59:20.050054 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 341: 14.14.14.10.http > 13.13.13.12.36439: Flags [P.], seq 1:276, ack 110, win 114, options [nop,nop,TS val 775995609 ecr 776021203], length 275: HTTP: HTTP/1.1 200 OK
15:59:20.050064 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.12.36439 > 14.14.14.10.http: Flags [.], ack 276, win 237, options [nop,nop,TS val 776021205 ecr 775995609], length 0
15:59:20.050067 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.12.36439: Flags [F.], seq 276, ack 110, win 114, options [nop,nop,TS val 775995609 ecr 776021203], length 0
15:59:20.050428 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.12.36439 > 14.14.14.10.http: Flags [F.], seq 110, ack 277, win 237, options [nop,nop,TS val 776021205 ecr 775995609], length 0
15:59:20.051037 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.12.36439: Flags [.], ack 111, win 114, options [nop,nop,TS val 775995610 ecr 776021205], length 0



15:59:28.399202 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 74: 13.13.13.13.38710 > 14.14.14.10.http: Flags [S], seq 862049736, win 29200, options [mss 1460,sackOK,TS val 776029554 ecr 0,nop,wscale 7], length 0
15:59:28.399828 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 74: 14.14.14.10.http > 13.13.13.13.38710: Flags [S.], seq 3854514688, ack 862049737, win 14480, options [mss 1460,sackOK,TS val 776003959 ecr 776029554,nop,wscale 7], length 0
15:59:28.399846 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.13.38710 > 14.14.14.10.http: Flags [.], ack 1, win 229, options [nop,nop,TS val 776029555 ecr 776003959], length 0
15:59:28.399902 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 175: 13.13.13.13.38710 > 14.14.14.10.http: Flags [P.], seq 1:110, ack 1, win 229, options [nop,nop,TS val 776029555 ecr 776003959], length 109: HTTP: GET / HTTP/1.1
15:59:28.400842 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.13.38710: Flags [.], ack 110, win 114, options [nop,nop,TS val 776003960 ecr 776029555], length 0
15:59:28.401867 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 341: 14.14.14.10.http > 13.13.13.13.38710: Flags [P.], seq 1:276, ack 110, win 114, options [nop,nop,TS val 776003961 ecr 776029555], length 275: HTTP: HTTP/1.1 200 OK
15:59:28.401879 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.13.38710 > 14.14.14.10.http: Flags [.], ack 276, win 237, options [nop,nop,TS val 776029557 ecr 776003961], length 0
15:59:28.401882 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.13.38710: Flags [F.], seq 276, ack 110, win 114, options [nop,nop,TS val 776003961 ecr 776029555], length 0
15:59:28.402251 00:1b:21:31:15:63 > 00:1c:67:ca:05:d3, ethertype IPv4 (0x0800), length 66: 13.13.13.13.38710 > 14.14.14.10.http: Flags [F.], seq 110, ack 277, win 237, options [nop,nop,TS val 776029557 ecr 776003961], length 0
15:59:28.402869 00:1c:67:ca:05:d3 > 00:1b:21:31:15:63, ethertype IPv4 (0x0800), length 66: 14.14.14.10.http > 13.13.13.13.38710: Flags [.], ack 111, win 114, options [nop,nop,TS val 776003962 ecr 776029557], length 0
^C
20 packets captured
20 packets received by filter
0 packets dropped by kernel

 

 

 

 

 

이상 끝

 

 

 

 

 

- 참조

https://ko.wikipedia.org/wiki/Wget

 

Wget - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. GNU Wget(간단히 Wget, 이전 이름: Geturl)는 웹 서버로부터 콘텐츠를 가져오는 컴퓨터 프로그램으로, GNU 프로젝트의 일부이다. 이 프로그램의 이름은 월드 와이드 웹

ko.wikipedia.org

https://serverfault.com/questions/496731/how-to-set-which-ip-to-use-for-a-http-request

 

How to set which IP to use for a HTTP request?

This is probably a silly question. I'm doing some http requests using wget from the command line, and I want those connections to be made through one specific IP of the 4 IPs my server has. Those h...

serverfault.com

 

'IT > Linux' 카테고리의 다른 글

CentOS7 네트워크 interface명 바꾸기  (0) 2022.02.17
[Linux] tar명령어  (0) 2020.04.12
[Linux] yum repository 변경  (0) 2020.04.12
[Linux] 리눅스 용량 확인 명령어 모음  (0) 2020.04.10
nf_conntrack table full dropping packet 로그  (0) 2019.12.27