How to issue a HTTP POST request?

Any workaround for the fetch command not supportingn the HTTP METHOD?

I would like to reset my ADSL modem, but I have two choices

  1. Issue a HTTP POST request
  2. Issua a TELNET command

Both ways seems impossible using Mikrotik scripts. Any advise would be welcome.

Thanks

Probably not possible on mikrotik. You could use metarouter or a small script on a PC.

I also need to do something very similar, basically, I love the “watchdog” feature, however, it may not be the router’s fault but instead be the modem’s fault, what i want to do is have a HTTP request sent to the modem to restart it at the same time as the watchdog restarts the router.

To be exact, here’s the exact HTTP (Represented by a CURL command) request I want to send:-

curl --data "ResetReq=1" 192.168.100.1/goform/RgConfig

I do have other PCs on in my household 24/7 (Data server, raspberry pi, windows desktop, linux laptop, etc…), however, I notice there’s a DHCP discrepancy with my modem’s DHCP server and the router’s DHCP client. Unless the router requests a DHCP address before the modem is connected to the internet, the router never really connects (Modem never issues the router the IP). Is there anyway to start a script that restarts the modem (Either on the router, or another PC) then wait until 192.168.100.1 is no longer replying to pings, then restart?

You obviously have a Motorola SurfBoard modem, which I’ve never had a problem with getting an IP from… no matter when I plug in the mikrotik.

Does the mikrotik get a new IP address if you reboot the mikrotik instead of rebooting the modem? If so, you can write a script to restart the mikrotik dhcp client service instead of rebooting the motorola modem.

If the modem isn’t connected to the internet when the router attempts to get an IP from the DHCP client, it’ll get an IP of 192.168.100.0/24 and a lease time of 20 seconds, it’ll continue to refresh every 20 seconds until the router is connected to the internet in which it’ll get the WAN IP as the DHCP IP and and a lease time of 3 days and 20 hours. However, if it connects to the router while it the router is connected to the internet, no IP what-so-ever is shown by the DHCP and I can’t connect to the internet. Exact same if I manual attempt to fiddle around with the DHCP client/etc (Enabling & disabling, swapping interfaces & back, etc…). The good thing that I can note is that the router boots up a hell of a lot faster than the modem connects to the internet, so, assuming they reboot at the same time, I’ve not had a single issue.

EDIT:- If I restart the router after the router has already successfully reconnected to the modem, it works fine, although, if I start the modem, wait till it’s online, then connect the router, it won’t work.

That’s not how the modem is supposed to work. Think about it, if that was a common problem, then every user who has their computer plugged into the modem would be calling their ISP everytime a power outage caused their PC and modem to go off. The modem would come on first and the user would later turn on the PC… and there would be no Internet access until the modem was power cycled.

So, I would say that you have a bad modem.

However, your question is how to workaround this. You can NOT do this directly with the mikrotik. You need the mikrotik to send a standard GET request to a PC (or your RasPi) that has an http server running, and when the PC receives the GET request from the mikrotik then it can send that POST request to the modem.

Although it may not be how it’s meant to work, it’s how mine works. I could go through the RMA process, but, it’s a working modem, and, even if it was up to par, it still doesn’t solve the fact that it may be the modem’s fault that I’m offline and the mikrotik router can’t restart it, eh?

However, what you said did spark an idea in my head, do you know how long the mikrotik router waits for the SMTP server to reply to it’s requests? If it waits awhile, I could just do something like:-

A. Listen on port T25 (I believe that’s SMTP? Whatever it is)
B. When I get a incoming connection from my router (I believe you can send emails from the router?), instantly send a http request to modem asking to restart it
C. Drop the socket on T25
D. Return to A

Would that work? How well does the router recover if the SMTP server just ‘drops’?

That should work fine. I just did a couple of tests, and the email on the router gracefully gives up after 60 seconds and says “timeout” in the log.

You can specify whatever port you want to use in the router to send the email.

Of course, you could also do an HTTP-FETCH and listen to port 80 instead of using the email function.

Thanks, I’ll throw together a little script tomorrow. Almost midnight today, I’m off to bed soon.

Once again, thanks for your help.