Tag Archives: ESTABLISHED

iptables Rules for my network

By Vaibhav.T

Hi Champs

i am new in Iptables and trying to write rules for my Samba server.I did some help from internet, created one script and run from rc.local :

#Allow loopback

iptables -I INPUT -i lo -j ACCEPT

# Accept packets from Trusted network

iptables -A INPUT -s my-network/subnet -j ACCEPT

# to allow established session to received traffic

iptables -A INPUT -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT

# to allow SSH on port 22 from my network

iptables -A INPUT -i eth0 -p tcp -s my-network/subnet –dport 22 -m state –state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp –sport 22 -m state –state ESTABLISHED -j ACCEPT

# To Allow incoming traffice on default SAMBA PORTS

iptables -A INPUT -p udp –dport 137 -j ACCEPT
iptables -A INPUT -p udp –dport 138 -j ACCEPT
iptables -A INPUT -p udp –dport 139 -j ACCEPT
iptables -A INPUT -p tcp –dport 139 -j ACCEPT
iptables -A INPUT -p tcp –dport 445 -j ACCEPT

#Enable Logging

iptables -A INPUT -j LOG
iptables -A INPUT -m limit –limit 2/min -j LOG –log-prefix “Iptables packet Drop” –log-level 7

# Drop all other Packets

iptables -A INPUT -j DROP

I also created one separate log file for iptables in /var/log/iptables.log and edit /etc/syslog.conf :

*.info;kern!=warning;mail.none;news.none;authpriv.none;cron.none /var/log/message

# Add new location

kern.warning /var/log/iptables.log

But my Drop packets are not showing in iptables.log file.Please let me know if i am doing wrong and let me know the correct way to write.I only want samba communication nothing else.

Thank You

Vaibhav

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to establish site to site vpn – Linux machine and cisco asa?

By ashokvpp

Hi,

I am trying to establish vpn between my linux server and cisco asa at client side.

I installed openswan on my cent os.

Linux Server

Code:

eth0 - 182.2.29.10 [ I have public IP]

Gateway - 182.2.29.1 [ and gw]

eth1 - 192.9.200.75 [ Internal Lan i/f]

I have simple IPtables Like
WAN="eth0"
LAN="eth1"
iptables -t nat -A POSTROUTING -o $WAN -j SNAT --to 182.2.29.10

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i $LAN -j ACCEPT
iptables -A INPUT -i $WAN -j ACCEPT

iptables -A FORWARD -i lo -j ACCEPT
iptables -A FORWARD -i $LAN -j ACCEPT
iptables -A FORWARD -i $LAN -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $WAN -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -s 192.9.200.0/255.255.255.0 -j ACCEPT
iptables -A FORWARD -d 192.9.200.0/255.255.255.0 -j ACCEPT

iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT


Client side Cisco ASA – Device

Code:

Provided details :

BD gateway ip is 212.2.7.15 [ Public IP]
Source IP :- 192.168.91.224
ESP-3DES-SHA1
Lifetime is 86400 seconds (Phase-1) & 3600 seconds (Phase-2)
Authentication is pre-shared


I need advise on configuring ipsec.conf and ipsec.secrets and what IP tables rules I need to add / modify.

Thanks

Best
Ashok

Source: FULL ARTICLE at The UNIX and Linux Forums

Help with iptables

By samnyc

Hi, I just build a Linux server, I said yes to enable the firewall. I only choose SSH conneciton. When I check the iptables. I see all of this (see below). I want to reject every thing only allow SSH from subnet 192.168.1.xx. Can you advise, how to do.

Code:

Chain RH-Firewall-1-INPUT (2 references)
pkts bytes target prot opt in out source destination
1043 3332K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 255
0 0 ACCEPT esp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT ah -- * * 0.0.0.0/0 0.0.0.0/0
15 2978 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 udp dpt:5353
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:631
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:631
540 44542 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 156 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
1532 142K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited


Source: FULL ARTICLE at The UNIX and Linux Forums

I have firewall rules to open ports, why telnet refuses connection?

By RedSpyder

Alright… this question comes from the fact that I’m trying to setup postfix to relay messages to Office 365 SMTP but its giving me connection refused… I read that if you have doubts if your port is open or not you should telnet to them so thats what I did.

This is a Red Hat 6.3 box.

My IP Table:

Code:

# Generated by iptables-save v1.4.7 on Fri Nov 16 14:20:30 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2755:248833]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --sport 21 -m state --state NEW -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --sport 20 -m state --state NEW -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 23 -j ACCEPT
-P OUTPUT ACCEPT
-A OUTPUT -m state --state NEW -p tcp --dport 587 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT


Output of

Code:

iptables -L -n


:

Code:

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:21 state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:20 state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:23
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:587


My telnet attempts:

Code:

[root@isvahlrtk01 logs]# telnet isvahlrtk01 587
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying 10.13.24.209...
telnet: connect to address 10.13.24.209: Connection refused
[root@isvahlrtk01 logs]# telnet isvahlrtk01 25
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying 10.13.24.209...
telnet: connect to address 10.13.24.209: Connection refused
[root@isvahlrtk01 logs]# telnet isvahlrtk01 23
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying 10.13.24.209...
telnet: connect to address 10.13.24.209: Connection refused
[root@isvahlrtk01 logs]# telnet isvahlrtk01 22
Trying 127.0.0.1...
Connected to isvahlrtk01.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3


Even though I have rules for ports 587,25,23… why can I only telnet succesfully only on port 22?

Arent I supposed to telnet all them correctly since I have firewall rules?
Could it be that my company is blocking those ports in THEIR firewall?

Source: FULL ARTICLE at The UNIX and Linux Forums

Script is ignoring  

By sathyaonnuix

Experts,

I am finding the split up of the Servers which uses the netstat on a specific port.

Code:

netstat -a | grep -w 9071 |grep ESTABLISHED | awk '{print $5}' | cut -d'.' -f1 | sort -n | uniq -c
1 ser7b
1 ser7c
2 ser7d
2 ser7e
1 ser7f
1 ser7h
1 ser7i
1 ser8b


I am trying to email this details:

Code:

print "

Split up on Port 9071:
$(netstat -a| grep -w 9070 |grep ESTABLISHED | awk '{print $5}' | cut -d'.' -f1 | sort -n | uniq -c" > file
cat file | sendmail -t


But when I open my email I can see all the servers split up are aligned in a single line rather than in “n”.

Code:

1 ser7b 1 ser7c 2 ser7d 2 ser7e.....


By googling found out that we need to add   to it, can you people help me with it. Thanks

Source: FULL ARTICLE at The UNIX and Linux Forums

[Solved] Script is ignoring  

By sathyaonnuix

Experts,

I am finding the split up of the Servers which uses the netstat on a specific port.

Code:

netstat -a | grep -w 9071 |grep ESTABLISHED | awk '{print $5}' | cut -d'.' -f1 | sort -n | uniq -c
1 ser7b
1 ser7c
2 ser7d
2 ser7e
1 ser7f
1 ser7h
1 ser7i
1 ser8b


I am trying to email this details:

Code:

print "

Split up on Port 9071:
$(netstat -a| grep -w 9070 |grep ESTABLISHED | awk '{print $5}' | cut -d'.' -f1 | sort -n | uniq -c" > file
cat file | sendmail -t


But when I open my email I can see all the servers split up are aligned in a single line rather than in “n”.

Code:

1 ser7b 1 ser7c 2 ser7d 2 ser7e.....


By googling found out that we need to add   to it, can you people help me with it. Thanks

Source: FULL ARTICLE at The UNIX and Linux Forums