Implementing Domain Name System - c

I am working on a project in embedded c.The project is the electronic Cash Register.In this
project i need to send the sale data through gprs on to a server our own made application
in C#. Now i have to change the ip of the server on the machine side because of dynamic ip.i
want to implement dns in my Machine so that idont need to change ip every time.plz anyone
in this.And what changes does i need to do on the server side.

Is your IP dynamic because of your ISP setup?
If so i'd say the easiest way would be to sign up to someone like no-ip.com. their free service will give you a url and an application to install on your server. When your ip changes on the server the application updates their records so the url is routed to the correct IP. Basically in short, going to the url there give you will alway go to your server.
Hope this helps.

I'm not sure that you want or need to implement a DNS server (and this is a very complex task, because DNS is a complex protocol, and you need to think of security issues). You only need to use a library call (like getaddrinfoand friends) which use eventually DNS to transform a host name to an IP address or vice versa.

Related

Kamailio: How to load balance calls among multiple Asterisk servers based on their IPs

My scenario is:
A SIP trunk is connected to a Kamailio server which is connected to multiple Asterisk servers locally and should load balance calls among these asterisk servers. How? There is a mysql database table inside Kamailio server which maps TO part of sip header of incoming calls to one of asterisks' IPs.
Kamailio should read sip header and search inside database and after getting IP, forward the call to the proper asterisk server.
For example, value of To inside incoming sip header is 123456 so kamailio does query database and finds number 123456 is inside 192.168.1.10 so call should be forwarded to server 192.168.1.10.
I have read multiple articles and Kamailio's help from it's website but couldn't find anything related to this scenario.
Does anyone know how to write the route inside kamailio.cfg?
There are some ways to do that. One of them is by using the dispatcher module.
This module offers SIP load balancer functionality and it can be used as a SIP traffic dispatcher. There are many load balancing and traffic dispaching algorithms that you can choose from, for example: round-robin, weight based load balancing, call load distribution, and hashing over SIP message attributes.
The module can be used as a stateless load balancer; it does not depend on any call state tracking module. It requires the TM module if you enable auto-discovery of active/inactive gateways.
It is very lightweight, therefore suitable for handling heavy SIP traffic. As the module has a small footprint and the ability to load balancing rules from a plain text file, it is suitable for embedded systems.
To make it work:
You need to add a dispatcher.list file with a list of the IPs of your asterisks like so:
1 sip:192.168.0.10 #asterisk 01
1 sip:192.168.0.11 #asterisk 02
Then before relaying the request you will do a ds_select_dst(1, 0);
Be sure that you specify the list file for your dispatcher module:
loadmodule "dispatcher.so"
modparam("dispatcher", "list_file", "/var/run/kamailio/dispatcher.list")
If you want to use a database instead of a file you can do that by specifying the db:
modparam("dispatcher", "db_url", "mysql://user:passwb#localhost/database")
Also, there are other parameters for specifying the database table etc.
You can read more in the kamailio dispatcher documentation
Just random or round-robin calling usualy done by dispatcher or loadbalance calling.
If you need query db, you choice is use AVPOPS module(which allow do custom query to db) and HTABLE for cache response.
avp_db_query("select password, ha1 from subscriber where username='$tu'",
"$avp(678);$avp(679)");
http://www.opensips.org/html/docs/modules/1.7.x/avpops.html#id293960
For sure you have also do PIKE and DDoS protection, becuase db can do much less sql queries then kamailio and/or attacking tools like SIPP/SIPSack. That bring down your db and hard to restore.

Use different IP address for every loop in running iMacros script

Can anyone help me with the iMacros? This will be my first time that i will use this. I need to create a script to visit a certain website but for each visit IP address should change for the website to count it as a unique visitor.
Here's what i have so far:
URL GOTO=http://sampleWebsite.com
WAIT SECONDS=10
SET !ERRORIGNORE YES
PROXY ADDRESS=192.168.4.5:80
BYPASS=http://sampleWebsite.com
I'm really not sure about the PROXY ADDRESS and BYPASS script part.
I don't think you can do that.
Your IP address is a property of your computer, not your browser.
Typically it is allocated dynamically via DHCP, but could be set statically via eg control panel.
In the DHCP case, you could in theory release the Ip address, and hope the DHCP server allocates a different one
hint: it probably wont.
In the static case, modification typically requires user interaction and administration permission.
However, assuming this website is public, and not on the local network, then it doesn't matter. The Ip address the website sees is your public IP, and this is set by the ISP. You have no control over this.
By the way, IP address is a terrible way of detecting unique visitors, as it doesn't allow for large corporate environments where hundreds/thousands of unique users will share one external IP.
It is more likely that the website would use additional information, for instance cookies, user agent strings etc. You might have better results if you modify the user agent string, and clear cookies

Service broker: initiator's address is changing, should I recreate existing dialogs?

One of the systems I work with sends some data to the remote target, for audit purposes. Everything is working fine, but now guys on the initiator's side are reconfiguring their network, so the initiator will soon have a different external IP address.
I understand that I will have to update firewall rules and route information on the target side. No changes in the service broker configuration have to be made on the initiator, as far as I can tell - the target server doesn't move anywhere.
The problem is, we use persistent dialogs. I have skimmed briefly through documentation, but haven't found whether I should drop and recreate existing conversations, or they will automatically pick up route changes.
If I understand it correctly, actual network address should be updated on-the-fly, since we don't specify it directly in the BEGIN CONVERSATION statement. But what seems logical for initiator, doesn't always apply to the target.
Did anyone have any experience with the situation described? Or, chances are, I have overlooked this in the documentation?
Any help is appreciated, thanks in advance.
You are correct.
You should just change the route on the target and that's it. The role of the route is exactly this, to separate the logical address ('service' name) from the physical location (hostname, IP address). Dialogs should survive network reconfiguration events w/o ever noticing the event.

How to access CouchDB server from another computer?

I created a couchDB on my computer, that is I used the Python line server = couchdb.Server('http://localhost:5984')
I want to share this database with two other colleagues. How can I make it available to them? For the moment, I am comfortable giving them full admin privileges until I get a better handle on this.
I tried to read the relevant parts of CouchDB: The Definitive Guide, but I still don't get it.
How would they access it? They can't just type in my computer's IP address?
In order to avoid NAT problems, I would use an external service like Cloudant or Iris Couch. You can replicate your local database against the common DB in the cloud and your colleagues can connect to it.
sure they can.
Start your server like this:
server = couchdb.Server('http://192.168.56.1:5984')
Where the IP address is the IP address of your PC. Find this out via the cmd prompt and ipconfig. Then they type in their python console
server = couchdb.Server('http://192.168.56.1:5984')
Yep, exactly the same. The IP identifies it for both you and everyone else. If you want them to access it in a browser then I guess you'll need to write that front end however.
If you are not on the same local network the the same more or less applies, except you'll have to add port forwarding into the mix.
I would use ngrok (https://ngrok.com/) its free and it will expose your localhost to colleagues in order to access the db.
once you download and execute, in the command line type ngrok http 192.168.56.1:5984 and they should be able to access it when you provide them the url ngrok returns, which exposes your localhost externally

GWT RPC Data Encryption and gwt-crypto issue

I have a GWT app, which is deployed on the app engine. The application is basically an exam simulator. All the exam questions and answers are stored in an XML file on the server. I use JAXB parser to parse the XML file and send a list of objects to the client through GWT RPC.
I noticed that during the transit (server -> client), the entire data is visible in plain text in Firebug. Since the data (exam questions and answers) are my intellectual property (IP) and something that I give lot of value to, I'm concerned that it's very easy to steal that data. Therefore, I'm trying to find ways to do some basic encryption and obfuscate the content when it's being sent over from the server to the client.
After Googling, I came across gwt-crypto project, and within a few minutes, I was able to achieve the exact result that I wanted. The server would encrypt the data, and the client would decrypt it. In Firebug, it would show the data in encrypted format, and not as plain text.
However, I ran into an issue. After implementing encryption/decryption, I noticed that my application would not load inside my company's network, which is obviously protected by a firewall. The application works perfectly from home or even on a 3G network on my phone. Another version of the application, which does not use encryption/decryption works perfectly from within my company's network. I confirmed this by creating 2 exact same versions of the app, with the only difference between a boolean flag, that determines whether encryption/decryption is enabled or disabled.
I have the following questions here:
What is the best way to achieve the result that I want to achieve? Is gwt-crypto a good solution for that? I'm fine with any simple approach to obfuscate the data during transit. It doesn't have to be a sophisticated algorithm.
What could be the possible reason for a GWT app, with encryption/decryption enabled, not working inside a firewall? I'm really clueless on this.
I'll appreciate any help on this issue.
Using SSL is the right way to go.
In your case, given AppEngine SSL limitations, you should load your HTML normally from non-SSL domain and use cross-site RPC to load your data via SSL domain.
Update:
What is the best way to achieve the result that I want to achieve?
If you want to secure the data in transit then the only secure option is SSL/HTTP. Usually it's also the simplest one as it does not require you to change the application code, just server configuration. In your particular case (appengine with private domain), it takes more work as described above.
Is gwt-crypto a good solution for that?
No. gwt-crypto uses a key to encrpt/decrypt the data. You also need a secure way to discribute this key.
I'm fine with any simple approach to obfuscate the data during transit.
Security through obscurity in not security. It's a false sense of security, which is even more dangerous than no security. It's enough that only one of the technically capable students cracks this and soon everybody would do it.
Possible attack would go like this:
Snoop the network, get username/password of user.
Login as that user, have browser load exam data, which is now unencrypted in memory.
Dump the DOM and inspect it for exam questions.
-
What could be the possible reason for a GWT app, with encryption/decryption
enabled, not working inside a firewall?
Use firebug to make sure network connections are identical, except for the encrypted content. Firewalls should not work that deep. Talk to sysadmin about it.

Resources