In this posts, we will try to understand what happens after the expiration of a ipv6 temporary address lifetime for a autoconfig client ( stateless ).
In SLAC, we typically derive our interface address based on our mac_address, and announcements from our local ipv6 router. These routers sends a RA ( router advertisements ), and within that RA, we have details about the prefixes or prefixes that the router carrys.
i.e
16:07:42.656846 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::209:fff:fe03:5882 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 56
hop limit 0, Flags [other stateful], pref medium, router lifetime 1800s, reachable time 0s, retrans time 0s
prefix info option (3), length 32 (4): 2001:444::/64, Flags [onlink, auto], valid time 2592000s, pref. time 3600s
0x0000: 40c0 0027 8d00 0000 000a 0000 0000 2001
0x0010: 0444 0000 0000 0000 0000 0000 0000
source link-address option (1), length 8 (1): 00:09:0f:03:58:82
0x0000: 0009 0f03 5882
note: I bold out a few entries that we will discuss in this blog.
These RA provides details to a ipv6 client for assigning the /64 network portion of the 128bit address.
You notice the gateway is not part of the RA announcement . So the clients will use the sender local-link for his own gateway. The onlink flag tells us this prefix is onlink.
So now a client that see this RA will now compute his address;
i.e
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:1f:5b:ea:0a:fa
inet6 fe80::21f:5bff:feea:afa%en0 prefixlen 64 scopeid 0x4
inet 192.168.254.20 netmask 0xffffff00 broadcast 192.168.254.255
inet6 2001:444::21f:5bff:feea:afa prefixlen 64 autoconf
media: autoselect (100baseTX <full-duplex,flow-control>)
status: active
And based on the RA preferred and valid fields, this address will be bind for that duration. After the preferred time has expired, the autoconfig client must re-new the address. If the host does not see another RA announcement, it will tag his interface as such;
i.e
ken-felixs-macbook:~ root# ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:1f:5b:ea:0a:fa
inet6 fe80::21f:5bff:feea:afa%en0 prefixlen 64 scopeid 0x4
inet 192.168.254.20 netmask 0xffffff00 broadcast 192.168.254.255
inet6 2001:444::21f:5bff:feea:afa prefixlen 64 deprecated autoconf
media: autoselect (100baseTX <full-duplex,flow-control>)
status: active
The deprecated tells us that this ipv6 address is not actively validate, but we can still use it up to the validate lifetime. It's recommended NOT to use the address for any communications if it's deprecated tho, and most OSes will try to honor that.
So how do we control this fucntion? This is done exclusively by the router issuing the RAs. Here's a few means for controlling this action;
fortigate ( 200A 4.0 patch 12 )
config system interface
edit "internal"
set vdom "root"
set ip 192.168.254.254 255.255.255.0
set allowaccess ping https ssh snmp
set type physical
set alias "inside"
config ipv6
set ip6-address 2001:444::1/64
set ip6-allowaccess ping https ssh snmp
set ip6-default-life 10
set ip6-other-flag enable
config ip6-prefix-list
edit 2001:444::/64
set autonomous-flag enable
set onlink-flag enable
set preferred-life-time 120
set valid-life-time 360
next
end
set ip6-send-adv enable
end
next
end
cisco ( ISR3825 ios 15.1.4 adventerprise )
!
interface GigabitEthernet0/0
ip address 1.1.1.253 255.255.255.0
ip nbar protocol-discovery
ip flow ingress
ip flow egress
ip nat inside
ip virtual-reassembly in
zone-member security inside
duplex auto
speed auto
media-type rj45
analysis-module monitoring
ipv6 address 2001:444::1/64
ipv6 enable
ipv6 nd prefix default 360 120
end
cisco ( ASA 9.1.1 )
!
interface vlan1
nameif inside
security-level 100
ip address 192.168.110.1 255.255.255.0
ipv6 address 2002:100::1/64
ipv6 nd ra-interval 30
ipv6 nd prefix default 360 120
ipv6 nd dad attempts 2
!
prefix info option (3), length 32 (4): 2002:100::/64, Flags [onlink, auto], valid time 360s, pref. time 120s
0x0000: 40c0 0000 0168 0000 0078 0000 0000 2002
0x0010: 0100 0000 0000 0000 0000 0000 0000
So in conclusion; Prefix valid/prefered times can be set within most RAs. This allow or give direction to the ipv6 clients as for the lifetime of use & that address
One thing I want to point out in my above 3 examples, fortinet offers controls per prefix that's announced on the local interface by default. You can have mutliple prefixes in the same fashion as having multiple ipv6 address and each one has unique configurations and valid/preferred values.
e.g
config ip6-prefix-list
edit 2001:444::/64
set autonomous-flag enable
set onlink-flag enable
set preferred-life-time 120
set valid-life-time 360
next
edit 2001:445::/64
set autonomous-flag enable
set onlink-flag enable
set preferred-life-time 24000
set valid-life-time 36000
next
With the cisco configurations shown above, effects all prefixes and are global to that interface. To simulate the same function as fortigate, you must enable the lifetime per-prefixes;
e.g
interface Vlan1
nameif inside
security-level 100
ip address 192.168.110.1 255.255.255.0
ipv6 address 2002:100::1/64
ipv6 address 2002:101::1/64
ipv6 nd ra-interval 30
ipv6 nd prefix default 360 120
ipv6 nd prefix 2002:101::/64 3600 1200
And now the RA will show the lifetime for each prefixes and the values set.
prefix info option (3), length 32 (4): 2002:100::/64, Flags [onlink, auto], valid time 360s, pref. time 120s
0x0000: 40c0 0000 0168 0000 0078 0000 0000 2002
0x0010: 0100 0000 0000 0000 0000 0000 0000
prefix info option (3), length 32 (4): 2002:101::/64, Flags [onlink, auto], valid time 3600s, pref. time 1200s
0x0000: 40c0 0000 0e10 0000 04b0 0000 0000 2002
0x0010: 0101 0000 0000 0000 0000 0000 0000
I hope you found this posting useful
Ken Felix
Freelance Network/Security Engineer
kfelix at hyperfeed d-o-t com
Sunday, March 10, 2013
Thursday, March 7, 2013
mailspam pot
In this post we will talk generally about the way to approach a mailspam like honey pot. I like to call this my own mailspam pot :)
here's a definition of a a honey port;
[QUOTE]
In computer terminology, a honeypot is a trap set to detect, deflect, or in some manner counteract attempts at unauthorized use of information systems. Generally it consists of a computer, data, or a network site that appears to be part of a network, but is actually isolated and monitored, and which seems to contain information or a resource of value to attackers.
[/QUOTE]
reference http://en.wikipedia.org/wiki/Honeypot_%28computing%29
Okay so here's my definition of a mailspam pot.
A hosted email MX server that's sets a trap or series of traps, and for collecting potential spammers, and those that use unethical means for harvesting email accounts. It uses a seeded site with a fictitious email address and/or a valid domain, and collects the spammer from_email address and it's mail relay ip address or other potential information.
Okay so in my spampot, I 'm using sendmail and the virutaluser feature. My virtual user table has one big wildcard entry that catches anybody sending to my trap domain.
e.g
-->
The column to the right within the virtusertable, is a mailalias that has hooks into a script that sorts the mailsender and collects his sender from_email_address and ip_address. This depends on mail log and the unix syslog services.
It greps the maillog for any mail received, and pulls this information out, & install it into a simple text file.
e.g ( snippet of my script )
cat maillog | grep ": from=<" | cut -d , -f1 | cut -d "=" -f2 >> mycollection.txt
I police that file and remove any duplicates, I also extract the dates, for post frensic and other analysis that I run. At this point, I can import these into my email security appliance, & apply them to my blacklist table. You have to be very creative as to what you do with the collected data.
As an alternative, once you have collected the sender ip_address, you can now check them against one of the realtime blacklister and see if they have entry or check them in let's say against a mail reputation system.
e.g
http://www.mxtoolbox.com/blacklists.aspx
http://blacklistcheck.com/
http://www.fortiguard.com/ip_rep.php
http://www.senderbase.org/senderbase_queries/detailip?search_string=8.8.8.8
NOTE: This could also confirm validity of their reputation.
The mail spampot is not a mitigation gear, nor takes any mitigation approach. As a matter of fact; it does not even prevent the spam mail. It's used to counter or harvest potential crawlers that finds emails and blindly send email to recipients. As additional matter of fact, we want it to catch spam.
In my design the spampot sits on a VM instance hosted in at a VPS, & uses very limit resources and best of all, it's non critical in function. http://www.vr.org/
In the above myspamspotdomain.com, that 's actually my true spampot domain, purchased just for my trap. Try not to get caught , I'm watching?
background;
I started the mailspam pot awhile back, to prove a hunch that domains that are registered are some how located and blindly spam'd. In my mailspampot domain, I never created any real accounts, sent any email from that domain, nor posted any thing on any website links with any reference or information about that domain.
NOTE: I personally think the registars are selling us out and our information when register domains.
When I first register my myspampotdomain, I had spam within the 1st 128hours after creating the domain and mx records in my dns. So a newly register domain with NO activity, had spam within 128hours of purchasing.
So any mail sent to anybody in that domain is considered spam.
My mailspampot version 2, which is planned in Q3-2013, will use a different approach and installed of running a text file, I plan on harvesting the following information;
and insert these into a mysql database.
For how much the spam pot catches, database logging is no required, but a Sql approach would look more professional.
Happy hacking
Ken Felix
Freelance Network/Security Engineer
kfelix a--t hyperfeed d--o--t com
here's a definition of a a honey port;
[QUOTE]
In computer terminology, a honeypot is a trap set to detect, deflect, or in some manner counteract attempts at unauthorized use of information systems. Generally it consists of a computer, data, or a network site that appears to be part of a network, but is actually isolated and monitored, and which seems to contain information or a resource of value to attackers.
[/QUOTE]
reference http://en.wikipedia.org/wiki/Honeypot_%28computing%29
Okay so here's my definition of a mailspam pot.
A hosted email MX server that's sets a trap or series of traps, and for collecting potential spammers, and those that use unethical means for harvesting email accounts. It uses a seeded site with a fictitious email address and/or a valid domain, and collects the spammer from_email address and it's mail relay ip address or other potential information.
Okay so in my spampot, I 'm using sendmail and the virutaluser feature. My virtual user table has one big wildcard entry that catches anybody sending to my trap domain.
e.g
-->
/etc/mail/virtusertable
@myspampotdomain.com myspampot
I could have seeded various email accounts like; root@myspampotdomain.com, admin@myspampotdomain.com,etc...
It greps the maillog for any mail received, and pulls this information out, & install it into a simple text file.
e.g ( snippet of my script )
cat maillog | grep ": from=<" | cut -d , -f1 | cut -d "=" -f2 >> mycollection.txt
I police that file and remove any duplicates, I also extract the dates, for post frensic and other analysis that I run. At this point, I can import these into my email security appliance, & apply them to my blacklist table. You have to be very creative as to what you do with the collected data.
As an alternative, once you have collected the sender ip_address, you can now check them against one of the realtime blacklister and see if they have entry or check them in let's say against a mail reputation system.
e.g
http://www.mxtoolbox.com/blacklists.aspx
http://blacklistcheck.com/
http://www.fortiguard.com/ip_rep.php
http://www.senderbase.org/senderbase_queries/detailip?search_string=8.8.8.8
NOTE: This could also confirm validity of their reputation.
The mail spampot is not a mitigation gear, nor takes any mitigation approach. As a matter of fact; it does not even prevent the spam mail. It's used to counter or harvest potential crawlers that finds emails and blindly send email to recipients. As additional matter of fact, we want it to catch spam.
In my design the spampot sits on a VM instance hosted in at a VPS, & uses very limit resources and best of all, it's non critical in function. http://www.vr.org/
In the above myspamspotdomain.com, that 's actually my true spampot domain, purchased just for my trap. Try not to get caught , I'm watching?
background;
I started the mailspam pot awhile back, to prove a hunch that domains that are registered are some how located and blindly spam'd. In my mailspampot domain, I never created any real accounts, sent any email from that domain, nor posted any thing on any website links with any reference or information about that domain.
NOTE: I personally think the registars are selling us out and our information when register domains.
When I first register my myspampotdomain, I had spam within the 1st 128hours after creating the domain and mx records in my dns. So a newly register domain with NO activity, had spam within 128hours of purchasing.
So any mail sent to anybody in that domain is considered spam.
My mailspampot version 2, which is planned in Q3-2013, will use a different approach and installed of running a text file, I plan on harvesting the following information;
- sender's email
- sender's ip_address
- date receipt
- message ID
and insert these into a mysql database.
For how much the spam pot catches, database logging is no required, but a Sql approach would look more professional.
Ken Felix
Freelance Network/Security Engineer
kfelix a--t hyperfeed d--o--t com
Tuesday, March 5, 2013
filtering bad tcp_flags
In this blog we will speak of filtering bad tcp_flags combos. TCP uses 6 primary flags for control of a tcp session. URG ACK PSH RST SYN FIN
A quick phrase to help remember the tcpflags and the ordering;
Unskilled
Attackers
Piss-Off
Real
Security
Folks
In the tcp 3-way handshake, ( SYN ; SYN-ACK ; ACK ) this is the ordering of the 1st three flags
that start EVERY tcp session.
In this tcp 3-way handshake, the client+server will issues certain unique information as of their MSS value, support for SACK and/or WindowScaling options,etc…..
After a TCP session has been established, we have some tcp_fag combinations that should never exist.
For example;
A SYN packet only comes with a SYN-ACK or by itself. So a SYN+FIN would not be a legit packet.
( what are you trying to do, start or finish a session )
Another example of a bad packet combination;
SYN+RST
( once again why would we try to start and reset a session )
Most bad tcp_flags combination are self-explanatory, but here’s a way to apply filtering for bad flag combinations.
(ios)
access-list 101 deny tcp any any syn fin ack
access-list 101 deny tcp any any ack fin psh rst syn urg
access-list 101 deny tcp any any rst syn
access-list 101 deny tcp any any rst syn fin ack
access-list 101 deny tcp any any rst syn fin
access-list 101 deny tcp any any syn fin
(ios-xr)
Tue Mar 5 11:04:19.248 GMT
ipv4 access-list badflags
10 deny tcp any any ack fin syn
20 deny tcp any any established fin psh syn urg
30 deny tcp any any rst syn
40 deny tcp any any established fin syn
50 deny tcp any any fin rst syn
60 deny tcp any any fin syn
!
(linux)
-p TCP --tcp-flags ALL FIN,URG,PSH -j DROP
-p TCP --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
-p TCP --tcp-flags SYN,RST SYN,RST -j DROP
-p TCP --tcp-flags SYN,FIN SYN,FIN -j DROP
-p TCP --tcp-flags SYN,ACK NONE -j DROP
-p TCP --tcp-flags RST,FIN RST,FIN -j DROP
-p TCP --tcp-flags SYN,URG SYN,URG -j DROP
-p TCP --tcp-flags ALL SYN,PSH -j DROP
-p TCP --tcp-flags ALL SYN,ACK,PSH -j DROP
(juniper)
filter
bad_flags {
term
badflgs {
from
{
source-address
0.0.0.0/0;
destination-address
0.0.0.0/0;
protocol
tcp;
source-port
[ 1024-65535];
destination-port
80;
tcp-flags
"fin | syn | rst | push | ack";
}
then
{
count
discarded;
discard;
}
}
term
default-rule {
/*
"from" anything else? */
then
{
count
accepted;
accept;
}
}
}
In all examples, bad tcp_flags combination
can be drop. If you have a stateful firewall, they should also drop these
packet also.
Keep in mind the following tcp rules;
- All tcp-datagram should have a flag set ( no null_flags )
- Likewise, ALL flags set is not validate either
- After the establishment of a tcp session, the SYN flag will never be seen again during that session
- The graceful way for tearing down a tcp session is with the FIN+ACK
- FIN-WAIT is not a flag ( it’s a state )
- MSS ( Max Segment Size ) is the max size of a single segment in a tcp flow, it’s not re-negotiated after the initial SYN and SYN-ACK of the 3way tcp handshake
Ken Felix
Freelance Network/Security Engineer
kfelix at hyperfeed dot com
Sunday, March 3, 2013
Avoiding TCP/UDP Port Exhaustion Cisco ASA v8.3 +
This blog will talk about ephemeral port exhaustion, reduction for ASA version 8.3+
In a Network Translation and with PAT ( port address transalation ) , a client source address and port numbers are mapped to a single NAT'd source. This is commonly called SNAT ( source NAT'ing ). Doing this for a hand full of clients machine is not critical. Since the src_port is expiring and temporary used and forever changing.
This process of temporary using a src_port is called "ephemeral". So take this machine that I'm typing this blog on;
The port#s in bold, are my ephemeral port that's short live. Every time I connect via my browser to a page or link, it will create a new session until that tcp session is torn down. Same if I ssh to an external host or conduct a dns query. The port number are always increasing in a round-robbin fashion.
So if you have a few thousands of machines doing this, and stacked behind one single /32 NAT host address, you can run out of available ports range. The available port-range is technically 0-65536, but common we only use the number 1024 and greater.
And port #0 is never to be used or seen, since it's reserved by IANA.
So how do we avoid this potential port exhaustion in a big enterprise networks ?
Simple, you need to create numerous NAT_pools and spread the SNAT around to allow for more possible connections.
So as in my earlier cisco router sample, the ASA is similar in approach and design.
1st
we create 4 object-groups for the networks ranges in my /16 network;
object network mynat_group1
description “ my range 10.100.{0-63).0/24 “
subnet 10.100.0.0 255.255.192.0
object network mynat_group2
description “ my range 10.100.{64-127).0/24 “
subnet 10.100.64.0 255.255.192.0
object network mynat_group3
description “ my range 10.100.{128-191).0/24 “
subnet 10.100.128.0 255.255.192.0
object network mynat_group4
description “ my range 10.100.{192-255).0/24 “
Next we build 4 static public global address for the PATs
-->
3rd
We now apply the nat mapping, in my example I'm using a a single inside/outside interfaces and to cover the /16 range;
So as you can we have means to control and eliminate ephemeral port exhaustion for cisco routers and firewalls.
Ken Felix
Freelance Network/Security Engineer
kfelix @ hyperfeed d-o-t com
In a Network Translation and with PAT ( port address transalation ) , a client source address and port numbers are mapped to a single NAT'd source. This is commonly called SNAT ( source NAT'ing ). Doing this for a hand full of clients machine is not critical. Since the src_port is expiring and temporary used and forever changing.
This process of temporary using a src_port is called "ephemeral". So take this machine that I'm typing this blog on;
sahel01:~
kfelix$ netstat -anb | grep 173.194.37
tcp4 0
0 172.72.16.252.50361 173.194.37.76.443 ESTABLISHED 13055289458842816507
16388355481610749693
tcp4 0
0 172.72.16.252.50358 173.194.37.36.443 ESTABLISHED 15459865186999302185
9569308347896001739
tcp4 0
0 172.72.16.252.50357 173.194.37.58.80 ESTABLISHED 15473202674970397607
15450657414193203890
tcp4 0
0 172.72.16.252.50353 173.194.37.36.80 ESTABLISHED 15449916008292693779
12065556332899070703
tcp4 0
0 172.72.16.252.50351 173.194.37.36.80 ESTABLISHED 15492483522701840990
3940907087701085868
tcp4 0
0 172.72.16.252.50350 173.194.37.36.80 ESTABLISHED 15477778475099826089
15062947145072305196
tcp4 0
0 172.72.16.252.50348 173.194.37.36.80 ESTABLISHED 15438052770712463118
3139346528096674657
tcp4 0
0 172.72.16.252.50347 173.194.37.36.80 ESTABLISHED 15488600259388646219
15127239438245289869
tcp4 0
0 172.72.16.252.50346 173.194.37.36.80 ESTABLISHED 15483982617081443018
10306197250605854565
tcp4 0
0 172.72.16.252.50343 173.194.37.36.80 ESTABLISHED 15455030726895744807
1904923687428027451
tcp4 0
0 172.72.16.252.50342 173.194.37.47.443 ESTABLISHED 15470383348861326017
14981341516604182217
tcp4 0
0 172.72.16.252.50341 173.194.37.58.80 ESTABLISHED 15481242668143010244
7539585777278819841
tcp4 0
0 172.72.16.252.50336 173.194.37.36.443 ESTABLISHED 15432894841306047757
2262450451104512765
tcp4 0
0 172.72.16.252.50333 173.194.37.74.80 ESTABLISHED 12970665585636111507
2756341486126288227
tcp4 0
0 172.72.16.252.50112 173.194.37.54.443 ESTABLISHED 1108777738390402656
2871967635688444387
The port#s in bold, are my ephemeral port that's short live. Every time I connect via my browser to a page or link, it will create a new session until that tcp session is torn down. Same if I ssh to an external host or conduct a dns query. The port number are always increasing in a round-robbin fashion.
So if you have a few thousands of machines doing this, and stacked behind one single /32 NAT host address, you can run out of available ports range. The available port-range is technically 0-65536, but common we only use the number 1024 and greater.
And port #0 is never to be used or seen, since it's reserved by IANA.
So how do we avoid this potential port exhaustion in a big enterprise networks ?
Simple, you need to create numerous NAT_pools and spread the SNAT around to allow for more possible connections.
So as in my earlier cisco router sample, the ASA is similar in approach and design.
1st
we create 4 object-groups for the networks ranges in my /16 network;
object network mynat_group1
description “ my range 10.100.{0-63).0/24 “
subnet 10.100.0.0 255.255.192.0
object network mynat_group2
description “ my range 10.100.{64-127).0/24 “
subnet 10.100.64.0 255.255.192.0
object network mynat_group3
description “ my range 10.100.{128-191).0/24 “
subnet 10.100.128.0 255.255.192.0
object network mynat_group4
description “ my range 10.100.{192-255).0/24 “
subnet 10.100.192.0 255.255.192.0
2ndNext we build 4 static public global address for the PATs
-->
object
network public1
description
” my public ip_address ending in
dot 201”
subnet 1.1.1.201 255.255.255.255
subnet 1.1.1.201 255.255.255.255
object network public2
description
” my public ip_address ending in
dot 202”
subnet 1.1.1.202 255.255.255.255
subnet 1.1.1.202 255.255.255.255
object
network public3
description
” my public ip_address ending in
dot 203”
subnet 1.1.1.203 255.255.255.255
subnet 1.1.1.203 255.255.255.255
object
network public3
description ” my public ip_address ending in dot 204”
subnet 1.1.1.204 255.255.255.255
subnet 1.1.1.204 255.255.255.255
3rd
We now apply the nat mapping, in my example I'm using a a single inside/outside interfaces and to cover the /16 range;
nat (inside,outside) source dynamic mynat_group1 public1
nat (inside,outside) source dynamic mynat_group2 public2
nat (inside,outside) source dynamic mynat_group3 public3
nat (inside,outside) source dynamic mynat_group4 public4
So as you can we have means to control and eliminate ephemeral port exhaustion for cisco routers and firewalls.
Ken Felix
Freelance Network/Security Engineer
kfelix @ hyperfeed d-o-t com
Friday, March 1, 2013
Avoiding TCP/UDP Port Exhaustion Cisco Router
This blog will talk about ephemeral port exhaustion.
In a Network Translation and with PAT ( port address transalation ) , a client source address and port numbers are mapped to a single NAT'd source. This is commonly called SNAT ( source NAT'ing ). Doing this for a hand full of clients machine is not critical. Since the src_port is expiring and temporary used and forever changing.
This process of temporary using a src_port is called "ephemeral". So take this machine that I'm typing this blog on;
sahel01: ~ kfelix$ netstat -an | head
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 112.22.1.172.58430 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58429 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58428 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58427 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58421 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58411 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58383 74.125.139.191.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58382 74.125.139.191.80 ESTABLISHED
The port#s in bold are my ephemeral port that's short live. Every time I connect via my browser to a page or link, it will create a new session until that tcp session is torn down. Same if I ssh to an external host or conduct a dns query. The port number are always increasing in a round-robbin fashion.
So if you have a few thousands of machines doing this, and stacked behind one single /32 NAT host addresss, you can run out of available ports range. The available port-range is technically 0-65536, but common we only use the number 1024 and greater.
And port #0 is never to be used or seen, since it's reserved by IANA.
So how do we avoid this potential port exhaustion in big enterprise networks ?
Simple, you need to create numerous NAT_pools and spread the SNAT around to allow for more possible connections.
Take this simple cisco configuration where the source network is a hughe 10.100.0.0/16. That along is over 64K machines or potential clients. And of then opening numerous ports for their tcp/udp sessions could drain a single ip_address if we where to PAT against one address ( /32 )
Here's the NAT ACLs for the source networks;
And now the rest of the NAT configurations;
So in this cfg you will notice we broke down the sources into ranges and then stacked them behind a single /32. The /16 was split into quarters ( 64 class C groupings ) and then any hosts in those groups would be NAT'd to the corresponding /32.
i.e
10.100.0.1- 10.100.63.255 into group 1
10.100.64.1- 10.100.127.255 into group2
10.100.64.128- 10.100.191.255 into group3
10.100.64.192- 10.100.255.255 into group4
So in the above, that will provide a fair amount of ephemeral-to-client port ratio. And hopefully not exhaust any src_ports upon a pike nat-translations.
We can even tweak port expiration from the nat process;
i.e
So be very careful of your ephemeral port-ranges to avoid exhaustion. I will show you during the next blogpost, how we prevent this with a cisco ASA running code 9.X using the same above networks.
Ken Felix
Freelance Network/Security Engineer
kfelix at hyperfeed dot com
In a Network Translation and with PAT ( port address transalation ) , a client source address and port numbers are mapped to a single NAT'd source. This is commonly called SNAT ( source NAT'ing ). Doing this for a hand full of clients machine is not critical. Since the src_port is expiring and temporary used and forever changing.
This process of temporary using a src_port is called "ephemeral". So take this machine that I'm typing this blog on;
sahel01: ~ kfelix$ netstat -an | head
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 112.22.1.172.58430 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58429 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58428 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58427 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58421 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58411 173.194.35.175.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58383 74.125.139.191.80 ESTABLISHED
tcp4 0 0 112.22.1.172.58382 74.125.139.191.80 ESTABLISHED
The port#s in bold are my ephemeral port that's short live. Every time I connect via my browser to a page or link, it will create a new session until that tcp session is torn down. Same if I ssh to an external host or conduct a dns query. The port number are always increasing in a round-robbin fashion.
So if you have a few thousands of machines doing this, and stacked behind one single /32 NAT host addresss, you can run out of available ports range. The available port-range is technically 0-65536, but common we only use the number 1024 and greater.
And port #0 is never to be used or seen, since it's reserved by IANA.
So how do we avoid this potential port exhaustion in big enterprise networks ?
Simple, you need to create numerous NAT_pools and spread the SNAT around to allow for more possible connections.
Take this simple cisco configuration where the source network is a hughe 10.100.0.0/16. That along is over 64K machines or potential clients. And of then opening numerous ports for their tcp/udp sessions could drain a single ip_address if we where to PAT against one address ( /32 )
Here's the NAT ACLs for the source networks;
ip access-list extended mynat_group1
permit ip 10.100.0.0 0.0.63.255 any
remark range 10.100.{0-63}.0/24
ip access-list extended mynat_group2
permit ip 10.100.64.0 0.0.63.255 any
remark range 10.100.{64-127}.0/24
ip access-list extended mynat_group3
permit ip 10.100.128.0 0.0.63.255 any
remark range 10.100.{128-191}.0/24
ip access-list extended mynat_group4
permit ip 10.100.192.0 0.0.63.255 any
remark range 10.100.{192-255}.0/24
!
And now the rest of the NAT configurations;
interface GigabitEthernet0/0
description Link to Internal_CORE
backup interface GigabitEthernet0/2
ip address 10.100.0.2 255.255.255.0
ip nat inside
!
interface GigabitEthernet0/1
description Link to TrackNetwork WAN Circuit ID:
ip address xxx.xxx.xxx.238 255.255.255.252
ip nat outside
!ip nat pool ephemeral-group1 xx8.xx4.x8.201 xx8.xx4.x8.201 netmask 255.255.255.0 ip nat pool ephemeral-group2 xx8.xx4.x8.202 xx8.xx4.x8.202 netmask 255.255.255.0 ip nat pool ephemeral-group3 xx8.xx4.x8.203 xx8.xx4.x8.203 netmask 255.255.255.0 ip nat pool ephemeral-group4 xx8.xx4.x8.204 xx8.xx4.x8.204 netmask 255.255.255.0!ip nat inside source list mynat_group1 pool ephemeral-group1 overloadip nat inside source list mynat_group2 pool ephemeral-group2 overload ip nat inside source list mynat_group3 pool ephemeral-group3 overloadip nat inside source list mynat_group4 pool ephemeral-group4 overload!ip route 0.0.0.0 0.0.0.0 xxx.xxx.xxx.237 name INTERNET_NEXT-HOP ip route 10.100.0.0 255.255.0.0 10.100.0.254 name STATIC_2_CORE
So in this cfg you will notice we broke down the sources into ranges and then stacked them behind a single /32. The /16 was split into quarters ( 64 class C groupings ) and then any hosts in those groups would be NAT'd to the corresponding /32.
i.e
10.100.0.1- 10.100.63.255 into group 1
10.100.64.1- 10.100.127.255 into group2
10.100.64.128- 10.100.191.255 into group3
10.100.64.192- 10.100.255.255 into group4
So in the above, that will provide a fair amount of ephemeral-to-client port ratio. And hopefully not exhaust any src_ports upon a pike nat-translations.
We can even tweak port expiration from the nat process;
i.e
ip nat translation udp-timeout 30 ip nat translation syn-timeout 45 ip nat translation icmp-timeout 30 ip nat translation port-timeout udp 53 20 ip nat translation port-timeout tcp 23 3600 ip nat translation port-timeout tcp 22 3600
The above will handle nat translation expiration to recover quicker , once these session goes idle and based on the number of seconds idle.So be very careful of your ephemeral port-ranges to avoid exhaustion. I will show you during the next blogpost, how we prevent this with a cisco ASA running code 9.X using the same above networks.
Ken Felix
Freelance Network/Security Engineer
kfelix at hyperfeed dot com
Subscribe to:
Posts (Atom)
