PDA

View Full Version : linux (fedora core 5) gateway question


wrongen
11-10-06, 05:54 AM
hi i have setup up a linux gateway using fedora core 5 for a firewall it works but i cant ping my server here is the script i used;

# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush - Flush all the rules in filter and nat tables
iptables --table nat --flush
iptables --delete-chain - Delete all chains that are not in default filter and nat table
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward - Enables packet forwarding by kernel

iptables -F
iptables -A INPUT -i lo -p all -j ACCEPT - Allow self access by loopback interface
iptables -A OUTPUT -o lo -p all -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT - Accept established connections
iptables -A INPUT -p tcp --tcp-option ! 2 -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -i eth0 --dport 21 -j ACCEPT - Open ftp port
iptables -A INPUT -p udp -i eth0 --dport 21 -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 22 -j ACCEPT - Open secure shell port
iptables -A INPUT -p udp -i eth0 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 80 -j ACCEPT - Open HTTP port
iptables -A INPUT -p udp -i eth0 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --syn -s 192.168.10.0/24 --destination-port 139 -j ACCEPT - Accept local Samba connection
iptables -A INPUT -p tcp --syn -s trancas --destination-port 139 -j ACCEPT
iptables -P INPUT DROP

my server as two ip address one for the WAN (internet) and LAN (intranet).
My 2nd NIC has an ip address of 205.155.10.1 which is for the lan, the other is 204.155.10.1 which is the the wan.

My other machines which my server is connected to spits out the following ip address's

IP: 205.155.10.1
Mask: 255.255.255.0
GW: 205.155.10.1
DNS: XXX.XXX.XXX.XXX

i can get on the internet and stuff but cant gain access to the webmin stuff where i need to be able to ping the server to do that

eth0 is 204.155.10.1 (WAN)
eth1 is 205.155.10.1 (LAN)
so does any one have any suggestions?

klingens
11-10-06, 06:01 AM
Don't write your own iptables scripts when you don't know what you're doing. I'm certain even fedora has a nice package which does proper NAT for you to simply install.

For starters, your WAN IP belongs to Tulare County Office of Education and your LAN IP belongs to California State University Network. Something looks very wrong there.

And having the IP and the gateway to be the same is... interesting to say the least.

su root
11-10-06, 05:42 PM
You can't ping your gateway because your default input rule is drop, and you don't have anything allowing it.

It looks like you have copied and pasted that from somewhere.. it's not a bad script, but if you aren't aware of the differences between public and private (RFC 1918) IPs, then that script is too complex for you, and is exposing things that you probably aren't expecting to be internet-accessible.

You need to re-assign all of your LAN IPs into a private range.

gorilly
11-14-06, 07:43 AM
ip tables tutorial http://iptables-tutorial.frozentux.net/iptables-tutorial.html

wrongen
11-15-06, 10:23 PM
i have worked it all out and it works thanx ppl for your help