The Community Forums

Interact with an entire community of cPanel & WHM users.
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using CPanel with NAT - Urgent!

Discussion in 'General Discussion' started by quortex, Jun 9, 2005.

  1. quortex

    quortex Member

    Joined:
    Mar 15, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Hi all,

    I have a really urgent problem if anyone can help me out I would seriously appreciate it.

    I have about 120 sites on different IP addresses. The IPs point to our hardware firewall and the firewall then NATs these IPs to our internal address. The internal address is a box that runs cpanel and has all the sites set to the boxes single IP. We cannot currently easily change this.

    So that allows our sites to look like they are on separate IP addresses to the outside world but they are all on one box and on one internal IP.

    Now when I add accounts to CPanel I have to then go into the DNS entry and change the internal IP address to the correct external IP I want to assign to that site. This works absolutely fine although it is a bit of a pain.

    The problem is that then if someone uses cpanel to add a subdomain etc. the apache configuration file is updated with the external ip address from dns rather than the internal ip address of the box. I need it to always put in the IP address assigned to the site rather than the IP assigned at the DNS level. This is the IP address shown when you list accounts.

    This must be a common problem? Is there a configuration option I can change so that this occurs? Or do I HAVE to create a script to go through the apache config etc. and correct the entries?

    Surely other people must use CPanel with this type of setup? Thanks in advance. Hope that all makes sense.

    Kind Regards,
    Mark
     
  2. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    If you go into the DNS section of the WHM menu, you'll see everything you need under "Edit Zone templates". There might be another way to do it, but as you need to be careful not to change the IP address of the machine this seems one of the best solutions.
     
  3. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Editing the Zone templates will also change the IP address in the httpd.conf
    to the one of the dns zone, in this case it is not good (server is behind nat)
    any other way for this to work ?
     
  4. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    Actually, if you hard code the IP in the zone templates, it doesn't change the IP httpd.conf uses for the IP at all as httpd.conf picks the IP set as the main shared IP not the IP in the DNS zone template.

    As a test, I did the following:

    1. WHM > Edit Zone Templates > standardvirtualftp

    2. Changed this line:

    Code:
    %domain%. IN A %ip%
    To this line:

    Code:
    %domain%. IN A 74.74.74.74
    3. Clicked Save button

    4. Created a new account cpfoo.foo on my machine in Create a New Account area

    5. Checked httpd.conf entries for it, which show the main shared server IP:

    Code:
    <VirtualHost 64.50.164.46:80>
        ServerName cpfoo.foo
        ServerAlias www.cpfoo.foo
        DocumentRoot /home/cpfoofo/public_html
        ServerAdmin webmaster@cpfoo.foo
    6. Checked /var/named/cpfoo.foo.db entries:

    Code:
    cpfoo.foo. IN A 74.74.74.74
    Changing the zone template does work and doesn't impact anything else on the system. It does exactly what it needs to do for NAT setups, which is keep the DNS entry as the external IP but all other entries on the machine as the internal IPs that were already set.
     
  5. deonsilva

    deonsilva Registered

    Joined:
    Jul 11, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Just want to confirm the suggestions mentioned here
    has worked for me in the pass, when using NAT.
     
  6. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    well i did follow your instructions however the ip on the httpd.conf changes to the external ip(212.30.211.48
    ) instead of the local ip (10.10.8.1).
    here is my standardvirtualftp configuration:

    ; cPanel %cpversion%
    ; Zone file for %domain%
    $TTL %ttl%
    @ %nsttl% IN SOA %nameserver%. %rpemail%. (
    %serial% ; serial, todays date+todays
    86400 ; refresh, seconds
    7200 ; retry, seconds
    3600000 ; expire, seconds
    86400 ) ; minimum, seconds

    %domain%. %nsttl% IN NS %nameserver%.
    %domain%. %nsttl% IN NS %nameserver2%.
    %domain%. %nsttl% IN NS %nameserver3%.
    %domain%. %nsttl% IN NS %nameserver4%.

    %nameserverentry%. IN A %nameservera%
    %nameserverentry2%. IN A %nameservera2%
    %nameserverentry3%. IN A %nameservera3%
    %nameserverentry4%. IN A %nameservera4%

    %domain%. IN A 212.30.211.48

    localhost.%domain%. IN A 127.0.0.1

    %domain%. IN MX 0 %domain%.

    mail IN CNAME %domain%.
    www IN CNAME %domain%.
    ftp IN A %ftpip%

    any idea ?
     
  7. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    Is your IP the internal IP in WHM > cPanel/WHM Basic Setup, so it shows as 10.10.8.1 in cPanel/WHM Basic Setup area? Because the DNS zones don't impact httpd.conf one iota. What does impact httpd.conf is what you have set for the IP in both IP Functions area as the main IP and what you have set for the IP in cPanel/WHM Basic Setup area. You should have the 10.10.8.1 IP set in WHM for IP Functions and cPanel/WHM Basic Setup area.
     
    #7 Miraenda, Jul 26, 2010
    Last edited: Jul 26, 2010
  8. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Yes, the WHM > cPanel/WHM Basic Setup, shows as 10.10.8.1
    and from some unknown reason it dose impact the httpd.conf
    so every time my client enter new domain or addon domain I need to edit back the httpd.conf back to 10.10.8.1
    the DNS zone is set correctly however to 212.30.211.48
     
  9. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    When you go to Change Site's IP Address area and click a domain to change the IP, which IP shows up as the shared IP there?
     
  10. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    It shows the 10.10.8.1
     
  11. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    Then I have no idea as my own machine doesn't work the way yours is, other people's hasn't who I've set up either and the DNS zone templates don't change the Apache configuration on a normal machine. I'd tell you to open a ticket about it but for the fact cPanel doesn't support NAT setups.

    All I can think is that you have a postwwwacct or some post account setup script that is modifying Apache configuration.
     
  12. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Would you be able to look at my server ?
    I don't mind to pay you if you solve this problem for me.
     
    #12 amlow, Jul 27, 2010
    Last edited: Jul 27, 2010
  13. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    I cannot contract for money per my employment, so unfortunately I couldn't look at the machine. I imagine there are other people here who would be willing to do that for money, though. If you don't have any offers on this post, there's a section to post for jobs here to pay and I'm sure someone would be willing to look into it.

    If I could help you, I would, so I'm sorry that I wouldn't be able to look at the machine. I do hope someone offers to help look at it, though.
     
  14. amlow

    amlow Member

    Joined:
    Jul 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Thanks Miraenda, I understand.
     
  15. Net Pro

    Net Pro Registered

    Joined:
    Aug 19, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Problems

    I have successfully configured my server behind NAT i had it working last night it stopped my external Ip is static to router and all ports forwarded to the local ip on server. Anyway the domain example.com wont got to the servers default page and the website wont show just shows internet explorer cannot display this webpage i even edited the zone template now I think Ive messed that up as I didnt need to configure this when it was working but I read through this forum and it recommended changing the line in dns zone file so I was wondering if this is why no domains point to the server default page????:confused::confused:
     
  16. octavc

    octavc Member

    Joined:
    Apr 11, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I have 2 servers behind nat.
    my zone template looks like this:

    ; cPanel %cpversion%
    ; Zone file for %domain%
    $TTL %ttl%
    @ %nsttl% IN SOA %nameserver%. %rpemail%. (
    %serial% ; serial, todays date+todays
    7200 ; refresh, seconds
    7200 ; retry, seconds
    2400000 ; expire, seconds
    86400 ) ; minimum, seconds

    %domain%. %nsttl% IN NS %nameserver%.
    %domain%. %nsttl% IN NS %nameserver2%.
    %domain%. %nsttl% IN NS %nameserver3%.
    %domain%. %nsttl% IN NS %nameserver4%.

    %nameserverentry%. IN A %nameservera%
    %nameserverentry2%. IN A %nameservera2%
    %nameserverentry3%. IN A %nameservera3%
    %nameserverentry4%. IN A %nameservera4%

    %domain%. IN A 123.123.123.123 ( change with your external ip)

    localhost.%domain%. IN A 127.0.0.1

    %domain%. IN MX 0 %domain%.
    %domain%. IN MX 10 %domain%.

    mail IN CNAME %domain%.
    www IN CNAME %domain%.
    ftp IN A 123.123.123.123 ( change with your external ip)

    In this matter works for regular domains . check to see if port 53 is open in your firewall router and point to your box

    For subdomains to work properly I must create a new cpanel account.

    So for example I need subdomain.site.com then I go to whm to the section
    "Create new account" and I create a new account with the name of the subdomain I want to.
    This is a cpanel issue, because before using cpanel I was using just a linux box with webmin on it and I didn't have any problems. Even the support team from cpanel couldn't help me.

    Also editing manualy httpd.conf is not a solution because it gets overwritten by cpanel software now and then and your changes are lost.

    Maybe someone has a different idea.
     
Loading...

Share This Page