I have an stm32H743 micro controller webserver (Cubeide LWIP) which displays a small webpage on my local LAN.
When I look at the router page, I see that all local IP's have a name associated with them.
Ethernet: COM-MID1 80:c7:55:94:12:14 192.168.1.115
STM32 00:80:e1:01:00:23 192.168.1.75
My question is - how do I change the name 'STM32' in my webserver code?
As you may imagine, there are thousands of references in my source code and I cant find the corresponding one. Where is it likely to be?
Thanks
Chris
Could it be that your router is presenting client host names from DHCP option 12?
With lwIP, you can specify the DHCP client host name by #defining the LWIP_NETIF_HOSTNAME option and then setting the hostname-field in the netif struct.
Related
Sorry if I have this in the wrong community but I'm hoping one of you can help me out anyway.
I have a web hosting account with a UK company who I'm happy with, but I'd like to set up a little hosting account from my laptop, just to see if it's possible and easy enough to do really.
Trouble is I've been doing a lot of research online but coming up empty whenit comes to more of a "complete guide". Do any of you know of a good resource for setting up a home server for publishing "Live" websites with custom TLD domain names? I have a localhost server running and files hosted on there but I'm really looking for help with the IP and DNS parts for the custom domains.
For reference, I have a machine running Win7, Appserv 2.5.10, UK broadband and a .co.uk domain name registered with 123-reg.
Any help would be hugely appreciated.
You'll need to:
Point your domain to your laptop.
If you get static public IP address from your ISP, then you can just point the A record to this IP address.
Where do I set this A record? Almost all domain registrars give you a nameserver for free. You point your domain to their nameservers (generally ns1.somedomain.com and ns2.samedomain.com etc.). In the nameserver config, create a A (stands for authoritative) record and put in your static IP address.
What if my ISP doesn't give me an static IP address? This is where services like dyndns come into picture. They give you an agent that you'll install on your laptop, it detects the change in IP address and automatically updates the Nameservers accordingly. There are some free variants of dyndns as well if you don't want to spend money on this.
But my laptops IP address is something like 192.168.x.x and my site runs on localhost (127.0.0.1)? Your laptop is most likely NATed. Think about your public IP address to be that of your router. You will need to forward any connection coming to your router on port 80 or 443 to your laptop's (192.168.x.x) corresponding ports. This is called Port-Forwarding and all routers support this. Port-Forwarding is done by logging on to the admin interface of your router (Many times its at http://192.168.0.1 or http://192.168.1.1).
But again my application is accessible at localhost? You need to make sure your apache/nginx listens on 0.0.0.0 or atleast 192.168.x.x interface. This is how computers outside your laptop will be able to make connection to your laptop on port 80/443.
I have been trying to learn socket programming in C++ and got some progress for the basics. But I understood that basics are not fundamentals.
One of those fundamentals is about the question which is stated in the title. Lets say I have two separate applications running on the same computer. One of them has a server socket and the other one has a client.
When the server gets an IP address automatically, how can client find the server? Do I have to assign an IP address that is known by the client? In that case, maybe that IP address is not available on the network.
Or can client find and connect to the server by sone kind of name or id?
Have the server bind to all interfaces and have the client lookup 'localhost' by name; it's resolved locally, (ie. no external DNS service required), to an IP address stored in a 'hosts' file, and is set by default to 127.0.0.1
Google 'hosts file'
The IP address of any server in the same host is 127.0.0.1 unless the server has bound to a specific, different IP address. As #MartinJames points out, you can use 'localhost' as the hostname for that, except on certain broken Linux distributions.
EDIT: Ugh I forgot to put this on Server Fault...
I have an Azure VM that is hosting a web application.
The application will be accessible via the VM's IP address:
http://191.238.112.62
I want to be able to use query strings to redirect to completely different sites that are within the local IIS. For example:
http://191.238.112.62/?site=1
would redirect to
www.site1.com
The way I have structured IIS can be seen below:
Each site has an entry in the systems host file.
127.0.0.1 wwww.site1.com
127.0.0.1 wwww.site2.com
127.0.0.1 wwww.site3.com
There is likely a better way to achieve what I am going for here so any pointers would be greatly appreciated.
Thanks.
Here is how I would do it. Not sure why you want to use query strings for this as IIS is made to do that if you configure it properly.
In your DNS server register all your websites to point to that IP. This is for when you go live. For development the hosts file is a good solution.
When you create the websites add a Host header like below
Now try loading any website by their full name
http://www.site1.com
http://www.site2.com
http://www.site3.com
Here is more info about IIS host headers.
Again, when you go live make sure you have the DNS set up for all the websites to point to the IP address of your server.
Hope this helps.
Edit based on comment:
Right, here is how I solved this in the past.
You can do all this with the hosts file but it's less painful if you have a proper DNS server to resolve the names.
The basic idea is to use slightly different URLs for development on the local machine.
All devs would have site1.com point to the IP of the shared server and site1.com.local point to 127.0.0.1. So a hosts file on a developer machine would look something like:
191.238.112.62 www.site1.com
127.0.0.1 www.site1.com.local
On all development machines you need to make sure you have the .local host header for all sites.
On the shared server you just need to add the right host headers and no hosts file changes. It's actually a bad idea to change the server hosts file.
I'm implementing the PASV mode in a FTP server, and I send to the client the IP address and port of the data end point. This is stupid because the IP is actually where the client is already connecting, so there ire two options:
How could I get the public IP
address from a given instance? Not
the VIP, but the public one.
How could I get the original target
IP address that the user used from
a Socket object? Considering routers and load balancers in the middle :P
An answer to any of this questions would do, although there is another way that could work... may I get the public IP address doing a DNS look up of myapp.cloudapp.net?
A fourth option would be use the Azure Management API library... but, too much trouble :P.
Cheers.
Not sure if you ever figured this out, but here's my take on it. The individual role instances are all behind the Windows Azure load balancer and have no idea what the original, outward-facing IP address is. Also, there's no Management API call that returns IP address - Get Deployment returns the URL but not the IP address. I think the only option is going to be a dns lookup.
Having said that: I don't think you can host a passive ftp server in your role instance (at least not elegantly). You may open up to 25 input endpoints on your role (up from 5 - see my recent blog post about this update), but there's manual work involved in the configuration. I don't know if your ftp application lets you limit your port range to such a small number of ports. Also:
You'd have to define each port as its own input endpoint (this is the manual labor part I mentioned) - input endpoints don't allow a port range to be specified, unlike the internal endpoints.
You'd have to specify the port number that's used internally, and the port numbers would need to be sequential
One last thing on ftp: you should be able to host an sftp server with no trouble, since all traffic comes through one port.
The hack that I'm contemplating right now is to retrieve http://www.icanhazip.com/. It isn't elegant and is subject to the availability of that service, but it gets the job done. A better solution would be appreciated!
This question is in terms of a RESTful ROA (Resource-Oriented Architecture). A resource on the Web has a URL (or URI if you prefer), for instance http://myserver.com/me.jpg.
You can get a file on the local (Windows) machine like this: file:///C:/MyPictures/me.jpg. This is not exactly a "Universal" Resource Identifier; it doesn't work right if you try it on a different machine. On your machine this may be a picture of you instead of me.
Suppose I want to design an application where files can be copied to a web service. Other users on other machines can download them from the web service, but if you are using it from the original machine they are fetched from the local file system for speed.
Is there any concept of a URI that refers to a file on a particular machine if it happens to be the local machine? Is there any concept of a URI for a particular machine? IP address isn't enough; my machine's IP address is 192.168.0.102 and yours may be too.
I would like to store a number of locations for the photo as first choice, second choice etc. First choice = file:///C:/MyPictures/me.jpg but only if the local machine is the machine it came from; second choice = http://myserver.com/me.jpg.
Another way of stating the same question: this machine is unique, and the file at C://somedir/somefile.jpg is unique. Does it have a unique address? An address that would yield either "No Route to Host" or the correct file, depending on where you requested it from?
Is there any concept of a URI that
refers to a file on a particular
machine if it happens to be the local
machine?
Let's follow the logic. How is this to be determined? The URI absolutely must contain a name which uniquely identifies the machine.
Hence, your machine must be identified by a publicly registered name. You have clearly identified that a private IP address is insufficient.
So, the answer is:
Your machine must be publicly accessible (via proxy if behind a firewall) by a publicly identified name.
That name must also resolve directly to your machine (not by a firewall) if you want efficiency in the "local running case".
Setting this up is machine dependent. But assuming you're behind a NAT firewall which supports virtual server proxies...
Register the unique name in the appropriate DNS server, have it resolve to the publicly-facing IP.
Set up a virtual server on your firewall proxying back to your internal address.
Set up a web-server on your local machine.
Ensure that your local machine itself is configured (in /etc/hosts or Windows equivalent) to map that public address to your 192.168 address.
That basically does it. Impossible to imagine how anything else would. No, it's not possible for a single URI to be defined as "Try file:// in this case, or default to http://". The very definition of URI is a single scheme, as described here:
http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
You're both correct and incorrect. While two computers can have the same name or the same ip address within a network segment, they only exist within that network.
If you want to uniquely identify a file and a machine, then file://blackbeauty.mydomain.org/c:\myfile.txt is perfectly acceptable, in the sense that the blackbeauty name is "owned" by mydomain.org.
So you will need a way to address machines in FQDN if you want the URL to be resolvable.