Created
September 6, 2018 18:50
-
-
Save muratgozel/5901700de605bc41397f45eb5e85eeb7 to your computer and use it in GitHub Desktop.
Which IP address is nginx or apache using while making outbound request?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Option: From the Terminal | |
# Get internal ip addresses | |
hostname -I | |
# Get the ip address which is starting with 10.XXX.XXX.XXX from the output. | |
# And place it in the command below. | |
wget --bind-address=10.XXX.XXX.XXX https://example.com | |
# 2. Option: From the shell script | |
#!/bin/bash | |
hostnames=$(hostname -I); | |
anchor_ip=$([[ "$hostnames" =~ 10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]] && echo $BASH_REMATCH); | |
wget --bind-address=10.XXX.XXX.XXX https://example.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment