출처: https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EA%B3%B5%EC%9D%B8_IP_%ED%99%95%EC%9D%B8


what is my IP in Linux
How to find out my public IP in Linux
리눅스 공인 IP 확인
리눅스 퍼블릭 IP 확인

1 방법 1: curl[편집]

  • curl로 각종 웹사이트들이 제공하는 정보 이용
명령어
curl bot.whatismyipaddress.com
curl http://ipecho.net/plain
curl icanhazip.com
curl ipv4.icanhazip.com
curl ipv4.ipogre.com
실행 예시
[root@zetawiki ~]# curl bot.whatismyipaddress.com
246.80.135.79
[root@zetawiki ~]# curl icanhazip.com
246.80.135.79
[root@zetawiki ~]# curl ipv4.icanhazip.com
246.80.135.79
[root@zetawiki ~]# curl http://ipecho.net/plain
246.80.135.79
→ 외부IP(공인 IP)
[root@zetawiki ~]# ifconfig -a | grep "inet " | grep "Bcast:" | awk '{print $2}' | awk -F: '{print $2}'
192.168.0.139
→ 내부IP

2 방법 2: ip route[편집]

ip route | awk '{print $NF;exit}'
[root@zetawiki ~]# ip route
246.80.135.0/24 dev eth0  proto kernel  scope link  src 246.80.135.79 
169.254.0.0/16 dev eth0  scope link  metric 1002 
default via 246.80.135.1 dev eth0
[root@zetawiki ~]# ip route | awk '{print $NF;exit}'
246.80.135.79

3 같이 보기[편집]

4 참고[편집]


+ Recent posts