Recommended Posts

So, if like me you've got BT's internet and have to use an echolife HG612 gateway and also run a server, you want your DNS to always be pointing to your IP even if it changes (Despite having a UPS, sometimes the line here drops for no reason and the IP changes).

So, I thought the ideal solution would be to just get the IP direct from the gateway itself! Now, I've reflashed my gateway to the stock echolife firmware so I have access to the web interface panel which this needs! Also note that it does some pretty lame output with the headers too. Anyway, this WILL need to be modified to work with your gateway I think, it works for mine with the specified WAN interface name!

Anyway, this in in PHP and uses CURL (I dislike CURL immensly but for some reason it wasn't liking my fsockopen and kept returning a piece of javascript code)

<?PHP
/*
	   Echolife WAN IP Retriever
	   Version 0.5
	   Created by n_K, 2012
	   Modify and use this script how you please.
*/
function DoCurl($URL, $POST = null, $Cookies = null)
{
		//Get a page using CURL.
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $URL);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_TIMEOUT, 6);
		curl_setopt($curl, CURLOPT_USERAGENT, 'EcholifeIPUpdater/0.5 (n_K)');
		curl_setopt($curl, CURLOPT_HEADER, true);
		if (!is_null($POST))
		{
				curl_setopt($curl, CURLOPT_POST, true);
				if (strlen($POST) > 2)
				{
						curl_setopt($curl, CURLOPT_POSTFIELDS, $POST);
				}
		}
		else
		{
				curl_setopt($curl, CURLOPT_POST, false);
		}
		if (!is_null($Cookies))
		{
				curl_setopt($curl, CURLOPT_COOKIE, $Cookies);
		}

		$result = curl_exec($curl);
		curl_close($curl);
		return $result;
}

function CurlCookies($Data)
{
		//Extract cookies from received data. (MODIFIED FOR USE WITH ECHOLIFE ONLY!)
		$Matches = preg_split('/Set-cookie:(.*?);/', $Data, -1, PREG_SPLIT_DELIM_CAPTURE);
		$i = 0;
		$Cookies = '';
		while ($i < count($Matches))
		{
				if ($i%2 == 1)
				{
						//Odd number-index!
						$Cookies .= $Matches[$i].'; ';
				}
				++$i;
		}
		$Cookies = substr($Cookies, 0, strlen($Cookies)-1);
		return $Cookies;
}

//Login to the modem as unpriviledged user and get the cookies
$Login = DoCurl('http://192.168.1.1/html/login.cgi?Username='./* PUT YOUR ECHOLIFE GATEWAY LOGIN USERNAME HERE */.'&Password='.rawurlencode(base64_encode(/* PUT YOUR ECHOLIFE GATEWAY PASSWORD HERE */)).'&Language=0&RequestFile=html/status/internetstatus.gz.html', 'a', 'Cookie=LoginTimes=0:LoginOverTime=0; FirstMenu=Admin_0; SecondMenu=Admin_0_0; ThirdMenu=Admin_0_0_0; sessionID=2222224564789011; Language=English');
$Cookies = CurlCookies($Login);

//Get the internet status page
$BigData = explode("\n", DoCurl('http://192.168.1.1/html/status/internetstatus.asp', null, $Cookies));
if (count($BigData) > 3)
{
		//Looks like we have some data to parse!
		foreach ($BigData as $ThisLine)
		{
				/* CHANGE YOUR GATEWAY INTERFACE BELOW TO WHAT IS DISPLAYED ON WAN PAGE 'WanPPP2' IN MY CASE */
				if (substr($ThisLine, 0, 14) == 'var WanPPP2 = ')
				{
						//We have it!
						$Data = $ThisLine;
						break;
				}
		}

		if (strlen($Data) > 5)
		{
				//Got it!
				/* CHANGE YOUR GATEWAY INTERFACE BELOW TO WHAT IS DISPLAYED ON WAN PAGE 'ptm1.101' IN MY CASE */
				$Data = explode(',', explode('ptm1.101",', $Data)[1]);
				/*
						0 = connected/not
						1 = IP
						2 = DNS servers
						3 = ?
						4 = ?
				*/
				if ($Data[0] == '"Connected"')
				{
						//Yay! We've got the IP!
						$IP = substr($Data[1], 1, (strlen($Data[1])-2));
						if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $IP, $BB) > 0)
						{
								//IP is in right format too!

/* PUT YOUR IP UPDATING/USING CODE HERE! */
						}
						else
						{
								//No valid IP found
						}
				}
				else
				{
						//Error, no connection!
				}
		}
		else
		{
				//Couldn't find WAN interface
		}
}
else
{
		//No data returned
}
?>

So there you go, maybe it'll be of use to someone!

Link to comment
https://www.neowin.net/forum/topic/1108769-getting-echolife-gateway-ip/
Share on other sites

"So, I thought the ideal solution would be to just get the IP direct from the gateway itself!"

Why is that? Why can you not just hit the update page of your dynamic dns provider from your server and have it use your source IP. This seems much more robust a solution than access your routers status page. And then you have to put in your code anyway to update your dyndns provider

/* PUT YOUR IP UPDATING/USING CODE HERE! */

Seems lot of extra steps when you could just hit the provider page and have it use the source IP your coming from as your update - this is how most of them work.

The servers have static IPs addressed as 192.168.1.x, and yes I could hit sites likes whatismyip.net and use them but there's no guarantee they're right, plus they might change the page layout/system like whatismyip.org which now has an image to stop you using it to get your IP in scripts.

Plus I don't have a dynamic IP providers, I've got 2 domains with DNS control on 123-reg (which was also a complete pain to get working via CLI).

And the last reason is that I've got multiple WAN connections, so the server that runs this script has internet out a different IP and interface than what the gateway is on so the IPs wouldn't be right anyway.

Who said anything about using whatmyip?

So your dns is hosted on 123 reg? I don't see anything on their site about adjustment of TTLs -- so even if your IP changes, what is the TTL if its anything more than a say a few minutes. Your server is going to be down for quite some time any any sort of IP change on your end. Not a optimal sort of setup at all, I would host your dns from a site that provides for dynamic updates and low ttls on the records.

No **** your servers behind your router are most likely going to have private ips -- if they were public it would be very unlikely that you were on a dynamic IP in the first place.

"so the server that runs this script has internet out a different IP and interface than what the gateway is on so the IPs wouldn't be right anyway."

Well that seems again like a pretty messed up way to do it ;) Why not just run the script on the server itself, or route the traffic to your update so it goes out the connection your servers would be accepting traffic on.

A simple http string quite often can update the IP that changes -- so for example on zoneedit with wget

wget -O - --http-user=username --http-passwd=password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.mydomain.com'

There you go your IP is updated using the source IP you came from - run this on the server your wanting to point to, and shazam your IP would be updated. This looks a lot simpler than your convoluted method to me.

Also any dns provider that supports dynamic updates would most likely have a client you could just run on the service. zoneedit for example has clients that run on windows, linux and mac. Also have cross platform support with java, perl and python.

Seems to me your wasting a lot of time reinventing the wheel without spending a couple of minutes looking to see how it can be done easier, faster and better.

Signing up to a dyndns service would mean I'd have to move my domains and pay extra (dyndns charge more than static DNS providers).

123-reg does it pretty secure, i.e. it's SSL ONLY and it's all ajax so you've got to go through a lot of tosh to get various pieces of information you need to change things.

Short TTL is crap anyway, get a short TTL and suddenly everywhere stops accepting your emails. Although 123-reg has TTL of 24 hours I've found if I clear my DNS cache it and retry it'll update without 10 minutes.

OK just a random problem that I found out about earlier, the refurbished PC we got had it's network card set to jumbo packets and I was wondering why hotmail just refused to load and only some pieces of data came through, very slowly, not sure if it's a hotmail issue or an issue with this modem or what but disabling jumbo frames fixed it completely, so just a warning to people :)

This topic is now closed to further replies.
  • Posts

    • Onkyo Dolby Atmos AV receivers are really solid deals by Sayan Sen Recently we covered great deals on several soundbar models from the likes of Sony, JBL, Samsung and others for really good prices (the lowest in several months). Aside from that we also reported on the Edifier S3000MKII, a hi-fi two-way bookshelf monitor that's available for only $800. Today we bring a list of AV receivers from Onkyo that are available at great prices including the Onkyo NR7100, RZ30, and 8470 (purchase links under the specs table down below). The Onkyo TX-NR7100 and Onkyo TX-RZ30 are both 9.2-channel AV receivers designed for immersive home theater setups but they occupy slightly different tiers within Onkyo’s lineup with the RZ30 positioned as the more advanced model. The TX-NR7100 is a THX Certified 9.2-channel receiver offering up to 100 W per channel (8 ohms, 2 channels driven). It supports Dolby Atmos, DTS:X, and IMAX Enhanced formats, with flexible configurations such as 5.1.4 or 7.1.2 speaker layouts. A key highlight is its built-in Dirac Live Room Correction which should help optimize sound based on your room and its acoustics. In comparison, both models share several core capabilities though the RZ30 is geared toward enthusiasts seeking more precise calibration and system flexibility, while the NR7100 is positioned as a slightly more accessible, value-focused option with strong all-round performance. The technical specs of the RZ30 and NR7100 9.2 AVRs are given in the table below: Specification Onkyo TX-RZ30 Onkyo TX-NR7100 Power Output (FTC, 2ch driven) ~100 W/ch (8Ω, 20Hz–20kHz, 0.08% THD) 100 W/ch (8Ω, 20Hz–20kHz, 0.08% THD) Dynamic / Peak Power 9 × 170 W (6Ω, 1kHz, 1% THD, 1ch driven) 220 W/ch (6Ω, 1kHz, 10% THD, 1ch driven) Frequency Response 5 Hz – 100 kHz (+1/-3 dB) 10 Hz – 100 kHz (+1/-3 dB) THD 0.08% 0.08% Room Correction Dirac Live (full bandwidth) Dirac Live (with AccuReflex support) Immersive Audio Dolby Atmos, DTS:X, IMAX Enhanced Dolby Atmos, DTS:X, IMAX Enhanced Speaker Layout Support Up to 7.2.2 / 5.2.4 / 9.2 processing Up to 7.2.4 / 5.2.4 / 9.2 processing HDMI Inputs / Outputs 6 inputs / 2 outputs (eARC) 6 inputs / 2 outputs (Main + Sub/Zone 2) HDMI 2.1 Support 8K/60, 4K/120, VRR, ALLM, QFT, DSC, eARC 8K/60, 4K/120, VRR, ALLM, QFT, DSC, eARC Video Formats HDR10+, Dolby Vision, HDCP 2.3 HDR10+, Dolby Vision, HDCP 2.3 Streaming / Network Wi-Fi, AirPlay 2, Chromecast, Bluetooth, DTS Play-Fi Wi-Fi, AirPlay 2, Chromecast, Bluetooth, DTS Play-Fi Get them at the links below: Onkyo TX-RZ30 9.2-Channel AV Receiver: $797.00 (Sold and shipped by Electronic Expo) Onkyo TX-NR7100 9.2-Channel AV Receiver: $699.00 (Sold and shipped by Adorma) Onkyo TX-8470 2 Ch Stereo Receiver: $449.00 (Sold and Shipped by Adorma) Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links or authorized dealer links (at the time of article publishing); ensure that you purchase from such links only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • A different thing with Russia. When you say is it better, depends on things. It is better that we don't have the E.U making rules and laws that have nothing to do with them. Is the trading part better? No, that is really mucked up, but then we knew that was going to happen and we would have make agreements, like we do with other parts of the world. Freedom of movement is certainly better, but could be improved, we still need more control over our borders. do you live in the U.K?
    • So what am I quoting from them? I never listened to what Farage or his cronies said. I wanted the U.K to leave the E.u years before the referendum and it had nothing to do with Farage and his cronies. So what country do you live in? Did we work much better together? We were always at logger heads with the E.U because we disagreed with them so much. Maggie was always on at them. I would have thought the E.U was glad to get rid of us as we stopped the integration or made it a two tier. Now without us they can integrate more. I would not have voted out if it was just a trading block and we can still work together on somethings.
    • MPC-BE 1.9.0 by Razvan Serea Media Player Classic - BE is a free and open source audio and video player for Windows. Media Player Classic - BE is based on the original "Media Player Classic" project (Gabest) and "Media Player Classic Home Cinema" project (Casimir666), contains additional features and bug fixes. The BE mod (Black Edition Mod) is a skinned version of Media Player Classic Home Cinema, much better looking than the plain old MPC. MPC-BE 1.9.0 changelog: Splitters Fixed crashes in some situations. AudioSplitter Added support for the RF64 format. Fixed reading of channel layout for some WavPack files. Added support for ID3 tags for Wave64 files. Unknown Wave64 chunks are now ignored. AviSplitter Added support for 'y408' video. Improved support for 'HEVC' video. FLVSplitter Added support for VVC video. MP4Splitter Improved handling of corrupted files. MatroskaSplitter Expanded support for V_UNCOMPRESSED video codecs. Fixed support for frame rotation (ProjectionPoseRoll). Improved support for "V_MS/VFW/FOURCC / HEVC". MpcDvdVideoDecoder Fixed conversion to YUY2. Fixed display of menus for some DVD-Videos. RoQVideoDecoder Output in NV12 and YV12 formats is allowed. Full range is used. MPC Video Decoder RGB32 format will be output as a top-down bitmap by default. Added support for the "IID_MediaSideDataDOVIMetadataV2" interface. Removed support for the deprecated "IID_MediaSideDataDOVIMetadata" interface. Fixed retrieving the name of the video adapter when using NVDEC. Fixed crashes in some situations. MPC Video Converter Added support for AYUV video format. MpcAudioRenderer Improved input format validation. Optimized retrieval of supported formats for exclusive mode. Added the "Keep audio device active when paused" setting. Fixed crashes and freezes in various situations. Subtitles Added the ability to open the properties of an external subtitle renderer in the "Subtitles" settings panel. Fixed external subtitle connections for VSFilter. Fixed a crash when rendering PGS/SUP subtitles when using AVX2. YouTube Improved support for yt-dlp. The built-in YouTube parser is no longer used. Player The HTTP read strategy has been changed. If the playlist contains one entry, more key combinations can be used to control the player (jump through chapters, adjust volume). Improved support for reading ASX playlists. The translation of the MediaInfo report for Chinese, Korean and Japanese has been removed. Added blocking of 32-bit filter "PICVideo Lossless JPEG Decompressor" (pvljpg20.dll), because it crashes. Added blocking of the system filter "AVI Decompressor", which will eliminate the crash of VFW codecs. Fixed a rare crash when using the "/slave" key. Fixed a crash when getting a list of fonts for OSD. Added the ability to load an external audio file using hotkeys. Fixed opening a network path starting with \?\UNC. The "Determine duration when adding" playlist setting now works for YouTube video URLs. The "Online media services" settings panel has been redesigned. Added a "Merge files using FFmpeg" option to the file saving dialog. This option is activated when playing multiple streams obtained using yt-dlp. Added loading of local .dpl playlists ("DAUMPLAYLIST"). Fixed a hang when the user closes the player during the URL opening process. Various interface fixes. Installer Updated MPC Video Renderer 0.10.5. Updated MPC Script Source 0.2.17. Added MPC Image Source 0.3.6. Translations Updated Japanese translation (by tsubasanouta). Updated Chinese (Traditional) and Dutch translation (by beter). Updated Romanian translation (by Andrei Miloiu). Updated Hungarian translation (by mickey). Updated Turkish translation (by cmhrky). Updated German translation (by Klaus1189). Updated Chinese (Simplified) translation (by wushantao). Updated Italian translation (by mapi68). Updated Korean translation (by Hackjjang). Updated Chinese (Traditional) (by udfbe). Updated libraries dav1d 1.5.3-6-g04b69f9; ffmpeg n8.2-dev-1857-g4653e68aab; libpng git-v1.6.55-9-g7d52a8087; Little-CMS git-lcms2.18-26-gf739cda; MediaInfo git-v26.05-38-g702c9b7fd; ZenLib git-v0.4.41-91-g073f297; zlib 1.3.2. Download: MPC-BE 64-bit | Portable MPC-BE 64-bit | ~20.0 MB (Open Source) Download: MPC-BE 32-bit | Portable MPC-BE 32-bit Link: Media Player Classic - BE Home Page Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Apple reportedly looks to blacklisted Chinese memory chips as RAM prices climb by Karthik Mudaliar Image via Apple Apple is reportedly trying to get a clearance from the Trump administration to buy memory from ChangXin Memory Technologies (CXMT) to get some relief from soaring DRAM prices. As per a report by the Financial Times, Apple approached the Commerce Department more than a month ago and also spoke to other officials and allies in Washington. For starters, CXMT is a company that's already been placed on the Pentagon's list of Chinese military companies. The Chinese company is the country's top DRAM maker. For Apple, the timing is certainly awkward but not surprising. Tim Cook had recently warned that Apple would have to raise prices because AI companies are buying up large amounts of memory for data centers, and just like that, Apple raised MacBook and iPad prices. Micron also recently revealed that customers have committed billions of dollars to secure memory supply years in advance, which shows us how aggressive securing infrastructure has become. This gives suppliers such as Samsung, SK Hynix, and Micron more leverage, while pushing hardware makers to look for alternatives. CXMT is one of those alternatives, but not the simplest one. Apple has spent many years trying to diversify parts of its supply chain away from China, especially for final assembly, while still depending heavily on Chinese manufacturing and suppliers. Even domestic brands from China are moving towards CXMT and YMTC instead of relying on Samsung, Micron, and SK Hynix. For Apple, though, it would invite more scrutiny than local Chinese companies. For now, this is more like a lobbying effort rather than a confirmed supply deal. There's no official statement from either of the parties. What is clearer, though, is the pressure behind such a request. AI demand has certainly made hardware a bottleneck, and companies are trying everything they can to bring things back to normal, even if that means making politically sensitive choices. Source: Financial Times
  • Recent Achievements

    • Week One Done
      flexorcist earned a badge
      Week One Done
    • One Month Later
      Woland13 earned a badge
      One Month Later
    • Week One Done
      Woland13 earned a badge
      Week One Done
    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      493
    2. 2
      +Edouard
      227
    3. 3
      PsYcHoKiLLa
      148
    4. 4
      Steven P.
      75
    5. 5
      FloatingFatMan
      70
  • Tell a friend

    Love Neowin? Tell a friend!