Getting an External IP Address - Programming On Unix
                
		         
	        
        
	
	Users browsing this thread: 1 Guest(s)
| 
 | |||
| 
					So I have a FreeBSD server that needs to know its external IP address and set it as an environment variable. So far, my method for doing this has been Code: EXTERNAL_IP="$(dig +short myip.opendns.com @resolver1.opendns.com)"Of course, this relies on (1) the IP not changing after boot and (2) opendns not going away. Does anyone have ideas on a more robust way of handling this problem? There's probably a very simple solution that I've completely overlooked :) | |||
| 
 | |||
| 
					the only method i know is to use some external resource Code: curl ifconfig.meCode: curl icanhazip.comCode: curl ipecho.net/plainCode: curl ifconfig.coCode: curl myexternalip.com/rawCode: wget -q -O - "http://myexternalip.com/raw"Code: fetch -q -o - "http://myexternalip.com/raw" | |||
| 
 | |||
| 
					@xero: It might be a good idea to make a script that pulls from multiple sources like that, and then compares the results and goes with what the majority of sources return. This way, if one source is down or returns a faulty result, the script will still work (and perhaps build something into the script that notifies the sysadmin of the failing source). | |||

 
                                			
 
                                			