views:

205

answers:

2

Consider the case of blogspot.com the domain is the one blogspot.com only but suppose i register in it with xxx then i will have xxx.blogspot.com like wise here it won't be the subdomain (i can smell) , but its some thing different ... how to achieve this ?? in j2ee web application..

A: 
  1. you need a DNS server that will resolve any subdomain as the adress of your server,
  2. you j2ee application can optain the hostname from the request header

UPDATE: here is a example of a BIND zone file:

$ttl 38400
mauriceperry.ch.    IN  SOA ks31441.kimsufi.com. maurice.mauriceperry.org. (
            1237374933
            10800
            3600
            604800
            38400 )
mauriceperry.ch.    IN  NS  ks31441.kimsufi.com.
mauriceperry.ch.    IN  NS  ns.kimsufi.com.
*   IN  A   213.186.61.21

Here xxx.mauriceperry.ch will resolve to 213.186.61.21 whatever xxx is.

Maurice Perry
i don't think that blogspot creates subdomain for each regustration..what say ?there should be some another tweak...
org.life.java
well, if you are using BIND, you can use a wildcard * in an A record
Maurice Perry
can you please explain it lite more ..
org.life.java
alright, I have updated my post with an example.
Maurice Perry
lemme configure this in my machine and will keep posting status here..
org.life.java
btw what are these values...1237374933 10800 3600 604800 38400 ?will it remain same for my case?
org.life.java
No, they should be adapted. I don't remember what they all are, but the first is a sort of version number that needs to be updated each time the zone file is updated, so that the other DNS servers know when a refresh is needed.
Maurice Perry
ok..lemme move ahead...
org.life.java
Refering this link:http://ulyssesonline.com/2007/11/07/how-to-setup-a-dns-server-in-ubuntu//etc/bind/named.conf.local# Our domain zonezone "mydomain.com" { type master; file "/etc/bind/zones/mydomain.com.db";};# For reverse DNSzone "200.1.192.in-addr.arpa" { type master; file "/etc/bind/zones/rev.200.1.192.in-addr.arpa";};
org.life.java
/etc/bind/named.conf.optionsoptions { directory "/var/cache/bind"; // If there is a firewall between you and nameservers you want // to talk to, you may need to fix the firewall to allow multiple // ports to talk. See http://www.kb.cert.org/vuls/id/800113 // If your ISP provided one or more IP addresses for stable // nameservers, you probably want to use them as forwarders. // Uncomment the following block, and insert the addresses replacing // the all-0's placeholder. forwarders { 192.1.200.1 }; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; };};
org.life.java
/etc/bind/zones/mydomain.com.db$TTL 3D@ IN SOA ns.mydomain.com. admin.mydomain.com. ( 2007062001 28800 3600 604800 38400);mydomain.com. IN NS ns.mydomain.com.jigar IN A 192.168.0.29www IN CNAME jigargw IN A 192.168.0.29 TXT "Network Gateway"* IN A 192.1.200.29
org.life.java
rev.0.168.192.in-addr.arpa$TTL 3D@ IN SOA ns.mydomain.com. admin.mydomain.com. ( 2007062001 28800 604800 604800 86400) IN NS ns.mydomain.com.29 IN PTR gw.mydomain.com.29 IN PTR jigar.mydomain.com.
org.life.java
this is my configuration..sorry to flood it like this, but got stuck here..error i am getting.. Stopping domain name service... bind9 rndc: connect failed: 127.0.0.1#953: connection refused
org.life.java
You should have more information about the error in /var/log/messages
Maurice Perry
finally done..! :) thanks
org.life.java
A: 
  1. Buy a domain name at you're favorite ISP.

  2. Configure for this domain a domain wildcard for the A record in the DNS zonefile (usualy using some nice tool from you're ISP):

    *   IN  A   74.125.77.191
    
  3. Code a Java Servlet (or whatever you are using) as front controller. The front controller will dispatch you to what ever the subdomain needs to show.

    String domain = request.getLocalName();
    String subdomain = domain.substring(0, domain.indexOf('.'));
    goto(subdomain); // or what ever you need for the subdomain
    
Kdeveloper
Thankx...can you help me what to do if i want to set up it in my local machine ?its linux..i have installed bind9i don't know the configuration ..
org.life.java
Bind is not exactly an easy package to configure correctly. I would rather advice using dnsmasq. But why go through all the trouble if you can buy for $2 a domain name at godaddy.com that includes a free DNS server? If you just want to do a proof of concept, you can just edit the /etc/hosts file and add the needed (sub)domains. Although no wildcards are allowed in the hosts file, you can add as many domains as you like.
Kdeveloper
Thanks for your time KDeveloper..finally done with it.
org.life.java
One more question i have is suppose i buy a domain over internet, then how i can i achieve this configuration ?i have temporarily locally configured this DNS but what if i want each node in internet to resolve this pattern , how can this reflect all DNS ?
org.life.java
The easies way is to use the DNS server of you’re ISP and configure the A record via their web interface.
Kdeveloper