Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
iptables help with subdomains, and internal ip's
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
d0ugb
n00b
n00b


Joined: 27 Feb 2004
Posts: 11

PostPosted: Tue Apr 04, 2006 8:18 pm    Post subject: iptables help with subdomains, and internal ip's Reply with quote

Okay, forgive me if i say anything incorrect here, im still pretty new with iptables. Here is my situation, I have 1 ipaddress from ISP, and im running bind on the same computer that i use to share my connection with the rest of my network. I use a base 10.0.0.x network, what i want to know is it possible to allow external access to to a subdomain mycomp.example.com even though it is on an internal address? For example i run a SSH serve on port 22 on my server, but i want to ssh directly into my subdomain using the same port 22 to connect, right now the only way i have been able to acomplish this is by connecting to the server then connecting to the internal machine. Is there anyway that i can do this? Thanks in advance. :?:
Back to top
View user's profile Send private message
Voorhees51
Guru
Guru


Joined: 05 Nov 2003
Posts: 358

PostPosted: Tue Apr 04, 2006 11:29 pm    Post subject: Reply with quote

use iptables to setup a NAT then use port forwarding
Back to top
View user's profile Send private message
aetius
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jul 2004
Posts: 118

PostPosted: Tue Apr 04, 2006 11:57 pm    Post subject: Reply with quote

more specifically, there are three steps you need to perform:

1) set up NAT so your internal addresses can get back out (I'm assuming you are doing this already)
2) redirect traffic on the firewall's external interface port to the internal host
3) allow the traffic to cross the router once redirected.

To redirect, you need to tell iptables to convert the destination IP to the internal IP:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -j DNAT --to-destination 10.0.0.5

10.0.0.5 being an example, and eth0 being your external interface.

Then, you have to allow that traffic across the FORWARD chain - otherwise it should be dropped by your drop policy (which is set, right?).

iptables -A FORWARD -i eth0 -d 10.0.0.5 -p tcp --dport 22 -j ACCEPT

again assuming eth0 is your external interface and the target address is 10.0.0.5.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum