Joshie the CK
08-17-2001, 07:41 PM
Okay... I've tried and tried, read man pages, howto's, NHF's, RFUHF's, and just about everything else..
But the iptable gods still seem to hate me..
First of all, it seems that the firewall is blocking the DHCP server from working on the internal lan...
Second, port forwarding works fine from a port like 8088, but try to forward 22, or 80, and nope. no-go..
Here, for your your humor at my expense, and laughing pleasure, is my rc.firewall:
#!/bin/bash
NET='209.20.211.36/255.255.255.0'
echo "1" > /proc/sys/net/ipv4/ip_forward
#Delete and flush.
iptables --flush
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
#Set Defaults
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
#iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
#Set up IP FORWARDING and Masquerading.
iptables -t filter -A FORWARD -d 0/0 -s 192.168.0.0/24 -o eth0 -j ACCEPT
iptables -t filter -A FORWARD -d 192.168.0.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 209.20.211.36/255.255.255.0 -d 0/0 -j ACCEPT
iptables -t filter -A INPUT -s 192.168.0.0/24 -d 0/0 -j ACCEPT
iptables -t filter -A OUTPUT -s 192.168.0.0/24 -d 0/0 -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -s 192.168.0.0/24 -d 0/0 -j ACCEPT
#iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
#guess it's not as easy as one line..
#forward hovelnet connection to proper places
#HIGHLY EXPERIMENTAL!!!
iptables -t nat -A PREROUTING -i eth1 -d 209.20.211.36 -p tcp --dport www -j REDIRECT --to-port 8080
#Internal LAN (eth1) rules
iptables -A INPUT -s 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 67:68 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 67:68 -j ACCEPT
#iptables -A OUTPUT -i eth1 -p tcp --dport 67:58 -j ACCEPT
#iptables -A OUTPUT -i eth1 -p udp --dport 67:68 -j ACCEPT
#######################
#External (eth0) rules#
#######################
#Allow connections to this machine.
iptables -A INPUT -s $NET -p tcp --dport 22 -j ACCEPT
#Forwards from external (eth0) to internal (eth1)
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 8088 -j DNAT --to 192.168.0.100:80
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 80 -j DNAT --to 192.168.0.101:80
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 21 -j DNAT --to 192.168.0.100:21
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 2222 -j DNAT --to 192.168.0.101:22
-----------------------------
So... All highly patched together from what I've been able to find, and pretty much experimental.
For some reason, that part to set up masquerading looks more complicated then it's supposed to be, and seems like something might be wrong with it.. But I just don't understand IPTABLES well enough to be able to figure it out..
At least I was able to put this much together on my own, eh? :)
Thanks in advance for any help/comments/criticism/laughing fits...
[ 17 August 2001: Message edited by: Joshie the CK ]
But the iptable gods still seem to hate me..
First of all, it seems that the firewall is blocking the DHCP server from working on the internal lan...
Second, port forwarding works fine from a port like 8088, but try to forward 22, or 80, and nope. no-go..
Here, for your your humor at my expense, and laughing pleasure, is my rc.firewall:
#!/bin/bash
NET='209.20.211.36/255.255.255.0'
echo "1" > /proc/sys/net/ipv4/ip_forward
#Delete and flush.
iptables --flush
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
#Set Defaults
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
#iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
#Set up IP FORWARDING and Masquerading.
iptables -t filter -A FORWARD -d 0/0 -s 192.168.0.0/24 -o eth0 -j ACCEPT
iptables -t filter -A FORWARD -d 192.168.0.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 209.20.211.36/255.255.255.0 -d 0/0 -j ACCEPT
iptables -t filter -A INPUT -s 192.168.0.0/24 -d 0/0 -j ACCEPT
iptables -t filter -A OUTPUT -s 192.168.0.0/24 -d 0/0 -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -s 192.168.0.0/24 -d 0/0 -j ACCEPT
#iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
#guess it's not as easy as one line..
#forward hovelnet connection to proper places
#HIGHLY EXPERIMENTAL!!!
iptables -t nat -A PREROUTING -i eth1 -d 209.20.211.36 -p tcp --dport www -j REDIRECT --to-port 8080
#Internal LAN (eth1) rules
iptables -A INPUT -s 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 67:68 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 67:68 -j ACCEPT
#iptables -A OUTPUT -i eth1 -p tcp --dport 67:58 -j ACCEPT
#iptables -A OUTPUT -i eth1 -p udp --dport 67:68 -j ACCEPT
#######################
#External (eth0) rules#
#######################
#Allow connections to this machine.
iptables -A INPUT -s $NET -p tcp --dport 22 -j ACCEPT
#Forwards from external (eth0) to internal (eth1)
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 8088 -j DNAT --to 192.168.0.100:80
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 80 -j DNAT --to 192.168.0.101:80
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 21 -j DNAT --to 192.168.0.100:21
iptables -A PREROUTING -t nat -p tcp -d $NET --dport 2222 -j DNAT --to 192.168.0.101:22
-----------------------------
So... All highly patched together from what I've been able to find, and pretty much experimental.
For some reason, that part to set up masquerading looks more complicated then it's supposed to be, and seems like something might be wrong with it.. But I just don't understand IPTABLES well enough to be able to figure it out..
At least I was able to put this much together on my own, eh? :)
Thanks in advance for any help/comments/criticism/laughing fits...
[ 17 August 2001: Message edited by: Joshie the CK ]