AWS 에서 접속 아이피 구하기(PHP)

아마존 서버를 사용시 서버 아이피를 구할 경우 사설아이피가 출력됩니다.
그래서 공인 아이피를 구하기 위해 만들었습니다.
<?
if(in_array(substr($_SERVER['SERVER_ADDR'], 0, 3), array('172')))
if(strrpos(gethostname(), '.compute.internal')!==false)
$_SERVER['SERVER_ADDR'] = file_get_contents('http://169.254.169.254/latest/meta-data/public-ipv4');
echo $_SERVER['SERVER_ADDR'];
?>
답글 남기기