LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2005, 03:14 AM   #1
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Rep: Reputation: 30
Dnat+fqdn


ok look at my situation


Internet ---> eth0(public ip) eth1(192.168.0.1 private ip) --->www.hello.com [192.168.0.2]
---->www.hi.com[192.168.0.3]
----> www.fine.com [192.168.0.4]
----> www.thanx.com[192.168.0.5]

Now is this possible by the following RULE

#IPTABLES -A PREROUTING -t nat -i eth0 -p tcp -d www.hello.com --dport 80 -j DNAT --to 192.168.0.2:80

#IPTABLES -A FORWARD -i eth0 -p tcp -d www.hi.com --dport 80 -j ACCEPT

*** and same stratigy for the rest of the stuffs also ****

I want to do this because i have only 1 public ip and lot's of stuff to do. so i am pointing these
websites to my lan machines. the public ip machine will be only used for DNAT and security
purposes.
 
Old 07-28-2005, 04:21 AM   #2
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
so? what exactly is the problem you are experienceing?
 
Old 07-28-2005, 04:58 AM   #3
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Original Poster
Rep: Reputation: 30
it give's me back a error messege.like

iptables v1.xxx: host/network www.hi.com.np not found
try iptables -h

now i have this type of configuration

my mail server ip is 202.79.55.xx. This ip holds web service and mail serevice of my company.

the dns is something like this

$TTL 86400
@ IN SOA mail.hi.com.np. admin.hi.com.np. (
2005011801 ; Serial
1800 ; Refresh
14400 ; Retry
14000 ; Expire
14000 ) ; Minimum

IN NS ns.hi.com.np.
IN MX 10 mail.hi.com.np.
IN A 202.79.55.xx

;localcal host entry
localhost IN A 127.0.0.1

; other entries
pop IN A 202.79.55.xx
smtp IN A 202.79.55.xx
ns IN A 202.79.55.xx
mail IN A 202.79.55.xx
IN MX 1 mail
ftp IN A 202.79.55.xx
www IN A 202.51.74.xx

now in the above www IN A 202.79.55.xx. This is a remote public ip of my branch office.in the branch office MASQUERADING is done.Now i went to the branch office and hit the following command
#IPTABLES -A PREROUTING -t nat -i eth0 -p tcp -d www.hello.com --dport 80 -j DNAT --to 192.168.0.2:80

now over here eth0 is my wan interface with the ip 202.51.74.xx.
192.168.0.2 is my local machine where i want to host my web stuffs. But This dnat is not working.May be my configuration is wrong?
 
Old 07-28-2005, 05:42 AM   #4
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
now that you have posted you problem and not just a statement we can continue :-)

you will not be able via iptables to define forwarding on the requested host address, since the host request is stated in the http header. iptables will not look into that header.
what you can do is to forwarding via ipaddress and port, so:
1. we tell iptables to forward any traffic on port 80 to 192.168.0.2 if it comes from outside your LAN
Code:
iptables -t nat -A PREROUTING -p tcp -s ! 192.168.0.0/24 --dport 80 -j DNAT --to-destination 192.168.0.2
2. you setup apache2 (or any other webserver) to use, either a different virtual host depending on the requested host name, or you setup the apache proxy module, that can redirect to another host on your network depending on the requested url

Last edited by Nathanael; 07-28-2005 at 05:44 AM.
 
Old 07-28-2005, 06:02 AM   #5
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Original Poster
Rep: Reputation: 30
ok thank you

i don't if i should ask you this question.In this case will i be able to host multiple websites on a single box?
and as your rule it has been said that what ever comes on port 80 send it to 192.168.0.2.Now in this way i will not be able to dnat to other ip .
my domain hi.com.np is not hosted on my branch office. as i have showed you my dns.it is hosted in the ip
202.79.55.xx. this machine holds my mail and ftp too. but for the web i have redirected it to another public ip which is my branch ip 202.51.74.yy.Now what happens is that

when someone from outside requests
www.hi.com.np it goes to the the isp side.then the isp replies that it is at 202.79.55.xx.But agian this ip says that www.hi.com.np is at 202.51.74.yy as you have see in the dns file i had previously posted. Now when the request comes to the 202.51.74.yy then i want it again to redirect to my lan ip 192.168.0.2.I want to do this by FQDN.Because tommorrow i will be hosting more sites on 192.168.0.2,192.168.0.3,192.168.0.4 etc.....

Is this possible or just my useless imaginary mind
 
Old 07-28-2005, 08:13 AM   #6
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
yes, you can host multible sites on a single box.
in apache2 you can specify the directive 'hostname' in your virtual host section. you run multiple virtual hosts, and specify each with a different hostname, then wenn a request hits the server it checks for the requested hostname and will fetch the data specified in that corresponding virtual host.

i am not quite sure about your domain http://www.hi.com.np/
basically i would say if you have dns configured that www to http://www.hi.com.np/ goes to your branch ip the browser will get that information correctly and contact the ip address set in dns for www and not dns entries for ftp, mx or smtp...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables+FQDN roopunix Linux - Networking 5 07-12-2005 08:10 AM
server FQDN help namboi Linux - Newbie 6 05-07-2005 02:20 PM
ip as my fqdn? sortia Linux - Networking 6 04-27-2005 09:46 AM
Fqdn ziox Linux - Networking 0 10-06-2004 05:46 PM
FQDN - not darb Linux - General 1 10-04-2004 03:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration