Kin Fat SZE
asked on
Can the firewall from linux (centOS 5) able to filter some of ip?
Dear Sir/Madam
I just install an linux (centOS 5) with oracle 11g.
When I setup the firewall of an linux (centOS 5), I have an question.
My question is can I set the firewall only able to be access from some of ip through the port 1521 to linux (centOS 5)?
(e.g.) the port 1521 only accessable from 192.168.0.1,192.168.0.2,19 2.168.0.3 to my oracle server (centOS 5), all the others are denied, will it possible?
Thanks
Francis SZE
Screenshot.png
I just install an linux (centOS 5) with oracle 11g.
When I setup the firewall of an linux (centOS 5), I have an question.
My question is can I set the firewall only able to be access from some of ip through the port 1521 to linux (centOS 5)?
(e.g.) the port 1521 only accessable from 192.168.0.1,192.168.0.2,19
Thanks
Francis SZE
Screenshot.png
I think you can do this using ipchains
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-fw.html
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-fw.html
that is iptables, ipchains are outdated.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Has anyone read my comment..the first one ?
Important Commands
Commands.pdf
Commands.pdf
Alternative Method
If you are using managed switch, you can achieve this goal by configuring access-list
If you are using managed switch, you can achieve this goal by configuring access-list
ASKER
Dear Sir/Madam
I would like to know if I only accept 192.168.123.x to access linux (centOS 5) through the port 1521.
The only things I sould do is as following?
After that, all finished?
After saved (/sbin/service iptables save), after reboot, I would have same setting as before?
I would like to know if I only accept 192.168.123.x to access linux (centOS 5) through the port 1521.
The only things I sould do is as following?
After that, all finished?
After saved (/sbin/service iptables save), after reboot, I would have same setting as before?
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 1521 -j ACCEPT
/sbin/service iptables save
yes however add
iptables -A INPUT -s -p tcp --dport 1521 -j DROP
if you change your default policy to ACCEPT in future time.
iptables -A INPUT -s -p tcp --dport 1521 -j DROP
if you change your default policy to ACCEPT in future time.
ASKER
So, I run following command once all done!?
Also, I would like to know what's meaning of 24 from the command line
iptables -A INPUT -s 192.168.123.0/<b>24</b> -p tcp --dport 1521 -j ACCEPT
Also, I would like to know what's meaning of 24 from the command line
iptables -A INPUT -s 192.168.123.0/<b>24</b> -p tcp --dport 1521 -j ACCEPT
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 1521 -j ACCEPT # using standard slash notation
iptables -A INPUT -s -p tcp --dport 1521 -j DROP
/sbin/service iptables save
24 shows the number of bits used as network. Your IP address is class C address which has by default 24 bits for network and 8 bits for host.
xxxxxxxx.xxxxxxxx.xxxxxxxx .hhhhhhhh
Where x are network bits.
xxxxxxxx.xxxxxxxx.xxxxxxxx
Where x are network bits.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Dear Sir/Madam
I would like to know the port number of samba?
Because I may need to share samba from the linux (centOS 5) to windows XP.
Thanks
Francis SZE
I would like to know the port number of samba?
Because I may need to share samba from the linux (centOS 5) to windows XP.
Thanks
Francis SZE
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
Hmm..and 445
ASKER
Dear sir/madam
Am I need to delete line7 "iptables -A INPUT -i eth0 -j ACCEPT"?
Is the following to open samba for anothers computer?
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
Manay Thanks
Francis SZE
Am I need to delete line7 "iptables -A INPUT -i eth0 -j ACCEPT"?
Is the following to open samba for anothers computer?
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
Manay Thanks
Francis SZE
ASKER
Dear sir/madam
I had input command as below , But the samba is not work fine.
anyone can help me!?
Many Thanks
Francis SZE
I had input command as below , But the samba is not work fine.
anyone can help me!?
Many Thanks
Francis SZE
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 445 -j ACCEPT
/sbin/service iptables save
access.PNG
ASKER
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 139 -j ACCEPT
/sbin/service iptables save
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.123.0/24 -p udp --dport 139 -j ACCEPT
/sbin/service iptables save
iptables -A INPUT --source 192.168.0.1 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT --source 192.168.0.2 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT --source 192.168.0.3 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -p tcp --dport 1521 -j DROP