Hi, Howard:
I am a Mandarin teacher and intend to establish my own moodle site in my home for students. So, I am the only one to managing all the things for the site and it really hard/take times for me to pickup the knowledge of network.
In the "Masquerading", it says "first get real DNS hostname " so I got one from dyndns.com.
"Then tweak internal DNS server" it said then, but I have no idea how to do it.
After reading your second message, I try to search "tweak internal DNS server" in the forums and it has nearly 30 discussions. I paste one below please check is it the right way to solve my problem? (Actually, it mentioned that is also from you.) If yes, then I will follow it to edit my config.php. (i.e. tweak internal DNS server ? )
There are two things I need to confirm with you. First, why its not the full IP address in $foo but only first two octets? secondly, "bar.org" represent the full DNS hostname, right?
Thanks for your patients!
To add to Alan's post, there are several ways of doing this, but the most elegant and more manageable is to use DNS. Try this:
- On your internal DNS server, add an address record to map "foo" to the internal IP address of the moodle server.
- Do the same on your external DNS server, so that the public sees "bar.org" mapped to the external publically accessible IP address.
- You may need to use a firewall rule to NAT the internal to external addresses.
To get the $CFG->wwwroot variable to change depending on who is accessing, you'll have to tweak it by pasting the following into config.php file (from the old masquerading trick by Howard Miller):
$foo = '192.168';
$client_ip = $_SERVER['REMOTE_ADDR'];
if (strpos($client_ip,$foo)===0) {
$CFG->wwwroot = 'http://foo';
} else {
$CFG->wwwroot = 'http://bar.org';
}
//$CFG->wwwroot = 'http://... previous entry';
I'm assuming that 192.168 are the first two octets of your internal IP address. Note that you *must* use a firewall to protect your servers from forgery of REMOTE_ADDR, so discuss the pros and cons of this method internally with your security team.