Monday, 28 January 2013

configuring linux system as router


echo 1 > /proc/sys/net/ipv4/ip_forward

/etc/sysctl.conf:
net.ipv4.ip_forward = 1

configure A for NAT

Now that we have a connection from A to B, we can tell A to share internet connection with B.
  • Go to computer A and share its internet connection with B by typing the two commands :
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
Now you do a ping test from remote system

ping 8.8.8.8  [ should be working ]

then check ping www.google.com   [ if not working then check for /etc/resolve.conf ]
  • Run this script on the host A :
#!/usr/bin/env bash
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig eth1 192.168.0.1 netmask 255.255.255.0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT


  • Run this script on the host B where xx.xx.xx.xx is your dns server :
#!/usr/bin/env bash
ifconfig eth0 down
ifconfig eth0 192.168.0.2 netmask 255.255.255.0
route del -net default 2>/dev/null
route add default gw 192.168.0.1 2>/dev/null
echo "nameserver xx.xx.xx.xx" > /etc/resolv.conf



few more links:

Sunday, 27 January 2013

squid proxy server: quick setup and how to










### Example of my squid configuration file ###



## Start By Amitmund
## to block the sites that are written at "/usr/local/etc/restricted-sites.squid"
acl BadSites dstdomain "/usr/local/etc/restricted-sites.squid" 
http_access deny BadSites
## It should ask for authentication to the users.
auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/squid_passwd
acl ncsa_users proxy_auth REQUIRED
## To block .mp3 and .exe files
acl FILE_MP3 urlpath_regex -i \.mp3
acl FILE_EXE urlpath_regex -i \.exe
http_access deny FILE_MP3
http_access deny FILE_EXE
http_access allow ncsa_users
## End By Amitmund


This is a quick note on how to setup the squid:
1. Install the package:
[Ubuntu] apt-get install squid
[Redhat] yum install squid

2. Its a nice idea to take a backup the original configuration file before changing the configuration. 
cp /etc/squid3/squid.conf /etc/squid3/squid.conf.original

3. Make sure squid runs after the system restart and start the process.
[Ubuntu]  sysv-rc-conf --level 2345 squid3  on
recheck:   sysv-rc-conf --list squid3
start the service: service squid3 start

[Redhat] chkconfig --levels 345 squid on
recheck: chkconfig --list squid
start the service: service squid start   [[ service state can be on of the following value{start/stop/restart/status} ]]

4. NOTE: 
Make sure, you restart the squid service when ever you update your configuration.
And to check the server is running or not [ pgrep squid ]
Your /etc/hosts file should be configured with your server’s hostname

You can also configure the squid [ if you want ] to display a different hostname: [ to do so... ]
# File: squid.conf 
visible_hostname CompanySquidServer1
  
Mis configured Squid instances will give an error like:
WARNING: Could not determine this machines public hostname.
Please configure one or set 'visible_hostname'.


Few example on doing things at squid.conf
5a. Restricting Web Access By Time:

You can create access control lists with time parameters. For example, you can allow only business hour access from the home network, while always restricting access to host 192.168.1.99.
 
You can start updating the file, near by line number close to 700 of squid.conf file.
 
#
# Add this to the bottom of the ACL section of squid.conf
#
acl officeHosts src 192.168.1.0/24
acl officeHours time M T W H F 9:00-18:00
acl RestrictedHost src 192.168.1.99

#
# Add this at the top of the http_access section of squid.conf
#
http_access deny RestrictedHost
http_access allow officeHosts officeHours
 
 
5b. Restricting Access to specific Web sites: 
 
Create the files that holds the website names. E.g:
 
 # File: /etc/squid/allowedSites.squid
www.google.com
www.yahoo.com
 
 # File: /etc/squild/restrictedSites.squid
www.badsite1.com
www.badsite2.com  
 
Now update your squid file to with the following ACL 

#File: squid.conf
acl AllowedSites dstdomain "/etc/squid/allowedSites.squid"
acl BlockedSites  dstdomain "/etc/squild/restrictedSites.squid"
#
# Add this at the top of the http_access section of squid.conf
#
http_access deny BlockedSites
http_access allow AllowedSites
 
NOTE: You can update your config to have multiple checks such as:
[  http_access allow officeHosts officeHours AllowedSites]  
 
5c. Password Authentication Using NCSA
Create the file which will have the username and password: 
 # touch /etc/squid/squid_passwd
# chmod o+r /etc/squid/squid_passwd

# htpasswd /etc/squid/squid_passwd user1
New password:
Re-type new password:
Adding password for user user1

Find your ncsa_auth file using the locate command.
# locate ncsa_auth
/usr/lib/squid/ncsa_auth

Edit squid.conf; 
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users
 
5d.Enforcing to use squid forward proxy server:
Transparent proxy configuration. 

Version 3.1+: squid.conf:
http_port 3128 transparent

Configuring iptables to Support the Squid Transparent Proxy 
[ Consider eth0 is connected to internet and eth1 is to the intranet/home network]. 
Only the Squid server has access to the Internet on port 80 (HTTP).
 
Note: Squid Server and Firewall – Same Server (HTTP Redirect).

If the Squid server and firewall are the same server,
all HTTP traffic from the home network is redirected to the firewall itself on the Squid port of 3128,
and then only the firewall itself is allowed to access the Internet on port 80.

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -A INPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -i eth1 -p tcp --dport 3128
iptables -A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o eth0 -p tcp --dport 80
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i eth0 -p tcp --sport 80
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -o eth1 -p tcp --sport 80

Note: This example is specific to HTTP traffic. 
You won't be able to adapt this example to support HTTPS web browsing on TCP port 443, 
as that protocol specifically doesn't allow the insertion of a "man in the middle" server for security purposes. 
One solution is to add IP masquerading statements for port 443, or any other important traffic, 
immediately after the code snippet. This will allow non HTTP traffic to access the Internet without being cached by Squid.

Squid Server and Firewall – Different Servers

If the Squid server and firewall are different servers, the statements are different.
You need to set up iptables so that all connections to the Web, not originating from the Squid server, 
are actually converted into three connections; 
one from the Web browser client to the firewall and another from the firewall to the Squid server, 
which triggers the Squid server to make its own connection to the Web to service the request. 
The Squid server then gets the data and replies to the firewall which then relays this information to the Web browser client.
The iptables program does all this using these NAT statements:

iptables -t nat -A PREROUTING -i eth1 -s ! 192.168.1.100 -p tcp --dport 80 -j DNAT --to 192.168.1.100:3128
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 -d 192.168.1.100 -j SNAT --to 192.168.1.1
iptables -A FORWARD -s 192.168.1.0/24 -d 192.168.1.100 -i eth1 -o eth1 -m state --state NEW,ESTABLISHED,RELATED \
-p tcp --dport 3128 -j ACCEPT
iptables -A FORWARD -d 192.168.1.0/24 -s 192.168.1.100 -i eth1 -o eth1 -m state --state ESTABLISHED,RELATED \
-p tcp --sport 3128 -j ACCEPT
 

Friday, 18 January 2013

Resetting ifconfig rx and tx value

Resetting ifconfig rx and tx value:

By default the rx and tx value get reset when ever the system get restart, but it is possible to do the same manually too, without the restarting the system.

Few Notes:
1. We get the rx and tx value from the ifconfig command.
2. It help us to find how much data came into the system and how much data went outside of the system
3. "rx" let us know about how much data came into (in coming ) the system
4. "tx" let us know about how much data went out (out going or data out ) from the system.
5. These information can also be found at "/proc/net/dev"[1] file


So, How do reset these information without restarting the system:

NOTE: This is a hacker way, to mask or delete these information, but the only way to save our server is to know how the hacker do this and how can we stop it or how to find that the system got hacked or so.

1. If you are doing from a remote system, then make sure that you are running this command with nohup and as root access.
2. Find the network driver information. [ example: "ethtool -i eth0"[2] or "ethtool -i wlan0"[3] ]
3. nohup sudo modprobe -r ath9k; sudo modprobe ath9k; sudo ifup wlan0 [ as example giving my system's wlan0 driver information ]
4. Note that the how will go out of network for some time in this case. [4]

Few more info:

1. You can find this command at the history file: as [ sudo modprobe -r r8169 ; sudo modprobe r8169 ; ifup eth0 ]
2. But a history can be cleared with -c option.
3. Check for some information at "/var/log/auth.log"[5] file. [ file at ubuntu os ]
4. Check for some information at "/var/log/kern.log"[6] file.
5. Check for some information at "/var/log/syslog"[7] file.

Outputs:

[1] $cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:  821480    7447    0    0    0     0          0         0   821480    7447    0    0    0     0       0          0
 wlan0: 2400453    2549    0    0    0     0          0         0   458347    2430    0    0    0     0       0          0
  eth0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

[1] $ifconfig
eth0      Link encap:Ethernet  HWaddr 54:04:a6:2d:2d:dd 
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:50 Base address:0xe000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:9419 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9419 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:984711 (984.7 KB)  TX bytes:984711 (984.7 KB)

wlan0     Link encap:Ethernet  HWaddr 74:2f:68:dd:74:5f 
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::762f:68ff:fedd:745f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3976 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3523 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3922646 (3.9 MB)  TX bytes:1141212 (1.1 MB)


[2] $ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version: rtl_nic/rtl8168e-2.fw
bus-info: 0000:05:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes


[3] $ethtool -i wlan0
driver: ath9k

version: 3.2.0-25-generic
firmware-version: N/A
bus-info: 0000:03:00.0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no

[4] $ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=54 time=22.7 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=54 time=23.0 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=54 time=22.2 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=54 time=23.5 ms
64 bytes from 8.8.8.8: icmp_req=5 ttl=54 time=22.3 ms
64 bytes from 8.8.8.8: icmp_req=6 ttl=54 time=22.9 ms
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
64 bytes from 8.8.8.8: icmp_req=17 ttl=54 time=24.6 ms
64 bytes from 8.8.8.8: icmp_req=18 ttl=54 time=24.1 ms
64 bytes from 8.8.8.8: icmp_req=19 ttl=54 time=22.9 ms


[5] $sudo cat /var/log/auth.log
Jan 19 03:40:40 amitmundlaptop sudo: amitmund : TTY=pts/1 ; PWD=/home/amitmund ; USER=root ; COMMAND=/sbin/modprobe -r ath9k
Jan 19 03:40:40 amitmundlaptop sudo: pam_unix(sudo:session): session opened for user root by amitmund(uid=1000)
Jan 19 03:40:41 amitmundlaptop sudo: pam_unix(sudo:session): session closed for user root
Jan 19 03:40:41 amitmundlaptop sudo: amitmund : TTY=pts/1 ; PWD=/home/amitmund ; USER=root ; COMMAND=/sbin/modprobe ath9k
Jan 19 03:40:41 amitmundlaptop sudo: pam_unix(sudo:session): session opened for user root by amitmund(uid=1000)
Jan 19 03:40:41 amitmundlaptop sudo: pam_unix(sudo:session): session closed for user root
Jan 19 03:40:41 amitmundlaptop sudo: amitmund : TTY=pts/1 ; PWD=/home/amitmund ; USER=root ; COMMAND=/sbin/ifup wlan0
Jan 19 03:40:41 amitmundlaptop sudo: pam_unix(sudo:session): session opened for user root by amitmund(uid=1000)
Jan 19 03:40:41 amitmundlaptop sudo: pam_unix(sudo:session): session closed for user root
Jan 19 03:40:47 amitmundlaptop sudo: pam_unix(sudo:session): session closed for user root
Jan 19 03:42:36 amitmundlaptop sudo: amitmund : TTY=pts/3 ; PWD=/var/log ; USER=root ; COMMAND=/usr/bin/tail -f kern.log
Jan 19 03:42:36 amitmundlaptop sudo: pam_unix(sudo:session): session opened for user root by amitmund(uid=1000)
Jan 19 03:42:42 amitmundlaptop sudo: pam_unix(sudo:session): session closed for user root
Jan 19 03:44:23 amitmundlaptop sudo: amitmund : TTY=pts/3 ; PWD=/var/log ; USER=root ; COMMAND=/usr/bin/tail -100 auth.log
Jan 19 03:44:23 amitmundlaptop sudo: pam_unix(sudo:session): session opened for user root by amitmund(uid=1000)


[6] $sudo cat /var/log/kern.log
Jan 19 03:40:40 amitmundlaptop kernel: [14993.181160] wlan0: deauthenticating from 6c:fd:b9:23:28:28 by local choice (reason=3)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288828] cfg80211: All devices are disconnected, going to restore regulatory settings
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288842] cfg80211: Restoring regulatory settings
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288852] cfg80211: Calling CRDA to update world regulatory domain
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441401] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441413] cfg80211: World regulatory domain updated:
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441419] cfg80211:     (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441428] cfg80211:     (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441437] cfg80211:     (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441446] cfg80211:     (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441455] cfg80211:     (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441464] cfg80211:     (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.517739] ath9k 0000:03:00.0: PCI INT A disabled
Jan 19 03:40:40 amitmundlaptop kernel: [14993.517784] ath9k: Driver unloaded
Jan 19 03:40:41 amitmundlaptop kernel: [14993.925284] cfg80211: Calling CRDA to update world regulatory domain
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937682] cfg80211: World regulatory domain updated:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937690] cfg80211:     (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937697] cfg80211:     (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937704] cfg80211:     (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937710] cfg80211:     (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937716] cfg80211:     (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937722] cfg80211:     (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.943370] ath9k 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
Jan 19 03:40:41 amitmundlaptop kernel: [14993.943385] ath9k 0000:03:00.0: setting latency timer to 64
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993786] ath: EEPROM regdomain: 0x60
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993787] ath: EEPROM indicates we should expect a direct regpair map
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993790] ath: Country alpha2 being used: 00
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993791] ath: Regpair used: 0x60
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993793] cfg80211: Updating information on frequency 2412 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993795] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993796] cfg80211: Updating information on frequency 2417 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993798] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993799] cfg80211: Updating information on frequency 2422 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993801] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993802] cfg80211: Updating information on frequency 2427 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993804] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993806] cfg80211: Updating information on frequency 2432 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993807] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993809] cfg80211: Updating information on frequency 2437 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993810] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993812] cfg80211: Updating information on frequency 2442 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993813] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993815] cfg80211: Updating information on frequency 2447 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993816] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993818] cfg80211: Updating information on frequency 2452 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993819] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993821] cfg80211: Updating information on frequency 2457 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993823] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993824] cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993826] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993827] cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993829] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993830] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993832] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993833] cfg80211: Updating information on frequency 2484 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993835] cfg80211: 2474000 KHz - 2494000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995363] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995479] ieee80211 phy0: Selected rate control algorithm 'ath9k_rate_control'
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995890] Registered led device: ath9k-phy0
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995897] ieee80211 phy0: Atheros AR9285 Rev:2 mem=0xffffc900057e0000, irq=17
Jan 19 03:40:41 amitmundlaptop kernel: [14994.055247] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 19 03:40:41 amitmundlaptop kernel: [14994.055458] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 19 03:40:44 amitmundlaptop kernel: [14996.956944] wlan0: authenticate with 6c:fd:b9:23:28:28 (try 1)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.958898] wlan0: authenticated
Jan 19 03:40:44 amitmundlaptop kernel: [14996.979553] wlan0: associate with 6c:fd:b9:23:28:28 (try 1)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.981997] wlan0: RX AssocResp from 6c:fd:b9:23:28:28 (capab=0x411 status=0 aid=1)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.982007] wlan0: associated
Jan 19 03:40:44 amitmundlaptop kernel: [14996.983796] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Jan 19 03:40:55 amitmundlaptop kernel: [15008.208271] wlan0: no IPv6 routers present



[7] $sudo cat /var/log/syslog:

Jan 19 03:40:40 amitmundlaptop wpa_supplicant[1072]: CTRL-EVENT-DISCONNECTED bssid=6c:fd:b9:23:28:28 reason=3
Jan 19 03:40:40 amitmundlaptop kernel: [14993.181160] wlan0: deauthenticating from 6c:fd:b9:23:28:28 by local choice (reason=3)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288828] cfg80211: All devices are disconnected, going to restore regulatory settings
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288842] cfg80211: Restoring regulatory settings
Jan 19 03:40:40 amitmundlaptop kernel: [14993.288852] cfg80211: Calling CRDA to update world regulatory domain
Jan 19 03:40:40 amitmundlaptop dhclient: receive_packet failed on wlan0: Network is down
Jan 19 03:40:40 amitmundlaptop NetworkManager[986]:    SCPlugin-Ifupdown: devices removed (path: /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlan0, iface: wlan0)
Jan 19 03:40:40 amitmundlaptop NetworkManager[986]: <info> (wlan0): now unmanaged
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441401] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441413] cfg80211: World regulatory domain updated:
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441419] cfg80211:     (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441428] cfg80211:     (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441437] cfg80211:     (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441446] cfg80211:     (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441455] cfg80211:     (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop kernel: [14993.441464] cfg80211:     (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:40 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: activated -> unmanaged (reason 'removed') [100 10 36]
Jan 19 03:40:40 amitmundlaptop wpa_supplicant[1072]: Failed to initiate AP scan.
Jan 19 03:40:40 amitmundlaptop kernel: [14993.517739] ath9k 0000:03:00.0: PCI INT A disabled
Jan 19 03:40:40 amitmundlaptop kernel: [14993.517784] ath9k: Driver unloaded
Jan 19 03:40:40 amitmundlaptop NetworkManager[986]: <info> (wlan0): deactivating device (reason 'removed') [36]
Jan 19 03:40:40 amitmundlaptop wpa_supplicant[1072]: Failed to initialize the driver after interface was added.
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): canceled DHCP transaction, DHCP client pid 8779
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <warn> (5) failed to find interface name for index
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: nm_system_iface_flush_routes: assertion `iface != NULL' failed
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <warn> (5) failed to find interface name for index
Jan 19 03:40:41 amitmundlaptop dnsmasq[8783]: exiting on receipt of SIGTERM
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> DNS: starting dnsmasq...
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): writing resolv.conf to /sbin/resolvconf
Jan 19 03:40:41 amitmundlaptop dnsmasq[9255]: started, version 2.59 cache disabled
Jan 19 03:40:41 amitmundlaptop dnsmasq[9255]: compile time options: IPv6 GNU-getopt DBus i18n DHCP TFTP conntrack IDN
Jan 19 03:40:41 amitmundlaptop dnsmasq[9255]: warning: no upstream servers configured
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): cleaning up...
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <warn> (5) failed to find interface name for index
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: (nm-system.c:685):nm_system_iface_get_flags: runtime check failed: (iface != NULL)
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <error> [1358547041.148097] [nm-system.c:687] nm_system_iface_get_flags(): (unknown): failed to get interface link object
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> Unmanaged Device found; state CONNECTED forced. (see http://bugs.launchpad.net/bugs/191889)
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> radio killswitch /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/ieee80211/phy0/rfkill4 disappeared
Jan 19 03:40:41 amitmundlaptop dbus[963]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
Jan 19 03:40:41 amitmundlaptop dbus[963]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jan 19 03:40:41 amitmundlaptop wpa_supplicant[1072]: Could not read interface wlan0 flags: No such device
Jan 19 03:40:41 amitmundlaptop kernel: [14993.925284] cfg80211: Calling CRDA to update world regulatory domain
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937682] cfg80211: World regulatory domain updated:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937690] cfg80211:     (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937697] cfg80211:     (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937704] cfg80211:     (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937710] cfg80211:     (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937716] cfg80211:     (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.937722] cfg80211:     (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.943370] ath9k 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
Jan 19 03:40:41 amitmundlaptop kernel: [14993.943385] ath9k 0000:03:00.0: setting latency timer to 64
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993786] ath: EEPROM regdomain: 0x60
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993787] ath: EEPROM indicates we should expect a direct regpair map
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993790] ath: Country alpha2 being used: 00
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993791] ath: Regpair used: 0x60
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993793] cfg80211: Updating information on frequency 2412 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993795] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993796] cfg80211: Updating information on frequency 2417 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993798] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993799] cfg80211: Updating information on frequency 2422 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993801] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993802] cfg80211: Updating information on frequency 2427 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993804] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993806] cfg80211: Updating information on frequency 2432 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993807] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993809] cfg80211: Updating information on frequency 2437 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993810] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993812] cfg80211: Updating information on frequency 2442 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993813] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993815] cfg80211: Updating information on frequency 2447 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993816] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993818] cfg80211: Updating information on frequency 2452 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993819] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993821] cfg80211: Updating information on frequency 2457 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993823] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993824] cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993826] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993827] cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993829] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993830] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993832] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993833] cfg80211: Updating information on frequency 2484 MHz for a 20 MHz width channel with regulatory rule:
Jan 19 03:40:41 amitmundlaptop kernel: [14993.993835] cfg80211: 2474000 KHz - 2494000 KHz @ 40000 KHz), (N/A mBi, 2000 mBm)
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995363] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995479] ieee80211 phy0: Selected rate control algorithm 'ath9k_rate_control'
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995890] Registered led device: ath9k-phy0
Jan 19 03:40:41 amitmundlaptop kernel: [14993.995897] ieee80211 phy0: Atheros AR9285 Rev:2 mem=0xffffc900057e0000, irq=17
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> found WiFi radio killswitch rfkill5 (at /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/ieee80211/phy0/rfkill5) (driver (unknown))
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]:    SCPlugin-Ifupdown: devices added (path: /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlan0, iface: wlan0)
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]:    SCPlugin-Ifupdown: device added (path: /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlan0, iface: wlan0): no ifupdown configuration found.
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <error> [1358547041.412046] [wifi-utils-nl80211.c:654] nl80211_wiphy_info_handler(): Don't know the meaning of NL80211_ATTR_CIPHER_SUITES 0x000fac06.
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): using nl80211 for WiFi device control
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <warn> (wlan0): driver supports Access Point (AP) mode
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): new 802.11 WiFi device (driver: 'ath9k' ifindex: 6)
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): exported as /org/freedesktop/NetworkManager/Devices/3
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): now managed
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): bringing up device.
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): preparing device.
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): deactivating device (reason 'managed') [2]
Jan 19 03:40:41 amitmundlaptop kernel: [14994.055247] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 19 03:40:41 amitmundlaptop kernel: [14994.055458] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: starting -> ready
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: unavailable -> disconnected (reason 'supplicant-available') [20 30 42]
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: ready -> inactive
Jan 19 03:40:41 amitmundlaptop NetworkManager[986]: <warn> Trying to remove a non-existant call id.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Auto-activating connection 'ssid_name'.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) starting connection 'ssid_name'
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: prepare -> config (reason 'none') [40 50 0]
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0/wireless): access point 'ssid_name' has security, but secrets are required.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: config -> need-auth (reason 'none') [50 60 0]
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: need-auth -> prepare (reason 'none') [60 40 0]
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: prepare -> config (reason 'none') [40 50 0]
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0/wireless): connection 'ssid_name' has security, and secrets exist.  No new secrets needed.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Config: added 'ssid' value 'ssid_name'
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Config: added 'scan_ssid' value '1'
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Config: added 'key_mgmt' value 'WPA-PSK'
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Config: added 'psk' value '<omitted>'
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> Config: set interface ap_scan to 1
Jan 19 03:40:43 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: inactive -> scanning
Jan 19 03:40:44 amitmundlaptop wpa_supplicant[1072]: Trying to authenticate with 6c:fd:b9:23:28:28 (SSID='ssid_name' freq=2412 MHz)
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: scanning -> authenticating
Jan 19 03:40:44 amitmundlaptop wpa_supplicant[1072]: Trying to associate with 6c:fd:b9:23:28:28 (SSID='ssid_name' freq=2412 MHz)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.956944] wlan0: authenticate with 6c:fd:b9:23:28:28 (try 1)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.958898] wlan0: authenticated
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: authenticating -> associating
Jan 19 03:40:44 amitmundlaptop kernel: [14996.979553] wlan0: associate with 6c:fd:b9:23:28:28 (try 1)
Jan 19 03:40:44 amitmundlaptop wpa_supplicant[1072]: Associated with 6c:fd:b9:23:28:28
Jan 19 03:40:44 amitmundlaptop kernel: [14996.981997] wlan0: RX AssocResp from 6c:fd:b9:23:28:28 (capab=0x411 status=0 aid=1)
Jan 19 03:40:44 amitmundlaptop kernel: [14996.982007] wlan0: associated
Jan 19 03:40:44 amitmundlaptop kernel: [14996.983796] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: associating -> associated
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: associated -> 4-way handshake
Jan 19 03:40:44 amitmundlaptop wpa_supplicant[1072]: WPA: Key negotiation completed with 6c:fd:b9:23:28:28 [PTK=CCMP GTK=CCMP]
Jan 19 03:40:44 amitmundlaptop wpa_supplicant[1072]: CTRL-EVENT-CONNECTED - Connection to 6c:fd:b9:23:28:28 completed (auth) [id=0 id_str=]
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): supplicant interface state: 4-way handshake -> completed
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0/wireless) Stage 2 of 5 (Device Configure) successful.  Connected to wireless network 'ssid_name'.
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) scheduled.
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) started...
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: config -> ip-config (reason 'none') [50 70 0]
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Beginning DHCPv4 transaction (timeout in 45 seconds)
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> dhclient started with pid 9316
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Beginning IP6 addrconf.
Jan 19 03:40:44 amitmundlaptop dhclient: Internet Systems Consortium DHCP Client 4.1-ESV-R4
Jan 19 03:40:44 amitmundlaptop dhclient: Copyright 2004-2011 Internet Systems Consortium.
Jan 19 03:40:44 amitmundlaptop dhclient: All rights reserved.
Jan 19 03:40:44 amitmundlaptop dhclient: For info, please visit https://www.isc.org/software/dhcp/
Jan 19 03:40:44 amitmundlaptop dhclient:
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) complete.
Jan 19 03:40:44 amitmundlaptop NetworkManager[986]: <info> (wlan0): DHCPv4 state changed nbi -> preinit
Jan 19 03:40:44 amitmundlaptop dhclient: Listening on LPF/wlan0/74:2f:68:dd:74:5f
Jan 19 03:40:44 amitmundlaptop dhclient: Sending on   LPF/wlan0/74:2f:68:dd:74:5f
Jan 19 03:40:44 amitmundlaptop dhclient: Sending on   Socket/fallback
Jan 19 03:40:44 amitmundlaptop dhclient: DHCPREQUEST of 192.168.1.2 on wlan0 to 255.255.255.255 port 67
Jan 19 03:40:47 amitmundlaptop dhclient: DHCPREQUEST of 192.168.1.2 on wlan0 to 255.255.255.255 port 67
Jan 19 03:40:47 amitmundlaptop dhclient: DHCPACK of 192.168.1.2 from 192.168.1.1
Jan 19 03:40:47 amitmundlaptop dhclient: bound to 192.168.1.2 -- renewal in 111704 seconds.
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info> (wlan0): DHCPv4 state changed preinit -> reboot
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info>   address 192.168.1.2
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info>   prefix 24 (255.255.255.0)
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info>   gateway 192.168.1.1
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info>   hostname 'dhcppc0'
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info>   nameserver '192.168.1.1'
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
Jan 19 03:40:47 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 5 of 5 (IPv4 Commit) started...
Jan 19 03:40:48 amitmundlaptop dnsmasq[9255]: exiting on receipt of SIGTERM
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> DNS: starting dnsmasq...
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> (wlan0): writing resolv.conf to /sbin/resolvconf
Jan 19 03:40:48 amitmundlaptop dnsmasq[9320]: started, version 2.59 cache disabled
Jan 19 03:40:48 amitmundlaptop dnsmasq[9320]: compile time options: IPv6 GNU-getopt DBus i18n DHCP TFTP conntrack IDN
Jan 19 03:40:48 amitmundlaptop dnsmasq[9320]: using nameserver 192.168.1.1#53
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> (wlan0): device state change: ip-config -> activated (reason 'none') [70 100 0]
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> Policy set 'sony' (wlan0) as default for IPv4 routing and DNS.
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) successful, device activated.
Jan 19 03:40:48 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 5 of 5 (IPv4 Commit) complete.
Jan 19 03:40:55 amitmundlaptop kernel: [15008.208271] wlan0: no IPv6 routers present
Jan 19 03:40:56 amitmundlaptop ntpdate[9367]: adjust time server 91.189.94.4 offset 0.031754 sec
Jan 19 03:41:04 amitmundlaptop NetworkManager[986]: <info> (wlan0): IP6 addrconf timed out or failed.
Jan 19 03:41:04 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 4 of 5 (IPv6 Configure Timeout) scheduled...
Jan 19 03:41:04 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 4 of 5 (IPv6 Configure Timeout) started...
Jan 19 03:41:04 amitmundlaptop NetworkManager[986]: <info> Activation (wlan0) Stage 4 of 5 (IPv6 Configure Timeout) complete.

Wednesday, 2 January 2013

Diet plan

Here’s the day-wise GM diet plan (along with a cheat-sheet)

Important: It is imperative to drink 12 to 15 glasses of water every day during the course of the diet.
No fruit juices (other then on day 7), tea, coffee or alcohol.
You can have black tea, black coffee or lime water (without sugar).
Moreover 45 minutes of workout daily or on alternate days helps in achieving superb results.

Day 1
Only fruits, with the exception of bananas, litchi, mangoes and grapes. Eat lots of watermelon, melon, pomegranates, apples, lime, oranges, strawberries and any other fruit that you like. Eat 20 times a day, if you want to, but only fruits.

**If you feel yourself craving for salt, then a tiny-winy ‘hajmola’ tab will help immensely.


Day 2
Only vegetables. Begin your day with one boiled potato with a tea-spoon of butter. For the rest of the day, eat only raw, boiled or otherwise cooked vegetables without oil. Don't eat more than one potato for the day. You can eat cabbage, carrots, cucumber, gourd and other vegetables. Add basil and oregano seasoning to them to make them more edible.

*If you make it through Day 2, then half the battle is won!

Day 3
Basically a combination of Day 1 and Day 2, which means you can eat fruits and vegetables of your liking, but no bananas or potatoes. Eat to your heart’s content and don’t forget to drink a lot of water.

Day 4
Bananas and Milk. You have the liberty to eat almost 6 bananas and have up to 4 glasses of milk. Though, you were told that bananas lead to weight gain, in this diet, the bananas act as a source of sodium and potassium, since your salt intake during the GM diet had reduced considerably. You can even have the highly diluted, yet yummy vegetable soup (tomatoes, onions, capsicum and garlic). It is such a respite after the three days on fruits and vegetables only.


Day 5
Another feast day where you can eat sprouts, tomatoes and cottage cheese (paneer). You could also eat chicken or soya chunks. Supplement your diet with the wonder soup. Increase the intake of water on account of the urea formation.


Day 6
Similar to Day 5, so you can eat sprouts, cottage cheese, chicken, soya chunks and other vegetables. No tomatoes. Supplement your diet with the wonder soup.


Day 7
It is the last day and you must be feeling very light and happy. This day you can have fruit juice, a bowl of rice or half roti, and any vegetable that you want to eat. If you are trying to lose to weight for a special occassion then you should try this diet at least two months before that. Also, you should maintain a gap of three to seven days between subsequent regimes.

Friday, 28 December 2012

Popular sorting algorithms


Bubble sort

Bubble sort is a simple sorting algorithm. The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, it swaps them. It continues doing this for each pair of adjacent elements to the end of the data set. It then starts again with the first two elements, repeating until no swaps have occurred on the last pass. This algorithm's average and worst case performance is O(n2), so it is rarely used to sort large, unordered, data sets. Bubble sort can be used to sort a small number of items (where its asymptotic inefficiency is not a high penalty). Bubble sort can also be used efficiently on a list of any length that is nearly sorted (that is, the elements are not significantly out of place). For example, if any number of elements are out of place by only one position (e.g. 0123546789 and 1032547698), bubble sort's exchange will get them in order on the first pass, the second pass will find all elements in order, so the sort will take only 2n time.



Selection sort

Selection sort is an in-place comparison sort. It has O(n2) complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.
The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive.


Insertion sort

Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and often is used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list. In arrays, the new list and the remaining elements can share the array's space, but insertion is expensive, requiring shifting all following elements over by one. Shell sort (see below) is a variant of insertion sort that is more efficient for larger lists.


Shell sort

 Main article: Shell sort
Shell sort was invented by Donald Shell in 1959. It improves upon bubble sort and insertion sort by moving out of order elements more than one position at a time. One implementation can be described as arranging the data sequence in a two-dimensional array and then sorting the columns of the array using insertion sort.
 

Comb sort

Comb sort is a relatively simple sorting algorithm originally designed by Wlodzimierz Dobosiewicz in 1980. Later it was rediscovered and popularized by Stephen Lacey and Richard Box with a Byte Magazine article published in April 1991. Comb sort improves on bubble sort, and rivals algorithms like Quicksort. The basic idea is to eliminate turtles, or small values near the end of the list, since in a bubble sort these slow the sorting down tremendously. (Rabbits, large values around the beginning of the list, do not pose a problem in bubble sort)

Merge sort

Merge sort takes advantage of the ease of merging already sorted lists into a new sorted list. It starts by comparing every two elements (i.e., 1 with 2, then 3 with 4...) and swapping them if the first should come after the second. It then merges each of the resulting lists of two into lists of four, then merges those lists of four, and so on; until at last two lists are merged into the final sorted list. Of the algorithms described here, this is the first that scales well to very large lists, because its worst-case running time is O(n log n). Merge sort has seen a relatively recent surge in popularity for practical implementations, being used for the standard sort routine in the programming languages Perl,[12] Python (as timsort[13]), and Java (also uses timsort as of JDK7[14]), among others. Merge sort has been used in Java at least since 2000 in JDK1.3.[15][16]

Heapsort

Heapsort is a much more efficient version of selection sort. It also works by determining the largest (or smallest) element of the list, placing that at the end (or beginning) of the list, then continuing with the rest of the list, but accomplishes this task efficiently by using a data structure called a heap, a special type of binary tree. Once the data list has been made into a heap, the root node is guaranteed to be the largest (or smallest) element. When it is removed and placed at the end of the list, the heap is rearranged so the largest element remaining moves to the root. Using the heap, finding the next largest element takes O(log n) time, instead of O(n) for a linear scan as in simple selection sort. This allows Heapsort to run in O(n log n) time, and this is also the worst case complexity.



Quicksort

Quicksort is a divide and conquer algorithm which relies on a partition operation: to partition an array an element called a pivot is selected. All elements smaller than the pivot are moved before it and all greater elements are moved after it. This can be done efficiently in linear time and in-place. The lesser and greater sublists are then recursively sorted. Efficient implementations of quicksort (with in-place partitioning) are typically unstable sorts and somewhat complex, but are among the fastest sorting algorithms in practice. Together with its modest O(log n) space usage, quicksort is one of the most popular sorting algorithms and is available in many standard programming libraries. The most complex issue in quicksort is choosing a good pivot element; consistently poor choices of pivots can result in drastically slower O(n²) performance, if at each step the median is chosen as the pivot then the algorithm works in O(n log n). Finding the median however, is an O(n) operation on unsorted lists and therefore exacts its own penalty with sorting.



Counting sort

Counting sort is applicable when each input is known to belong to a particular set, S, of possibilities. The algorithm runs in O(|S| + n) time and O(|S|) memory where n is the length of the input. It works by creating an integer array of size |S| and using the ith bin to count the occurrences of the ith member of S in the input. Each input is then counted by incrementing the value of its corresponding bin. Afterward, the counting array is looped through to arrange all of the inputs in order. This sorting algorithm cannot often be used because S needs to be reasonably small for it to be efficient, but the algorithm is extremely fast and demonstrates great asymptotic behavior as n increases. It also can be modified to provide stable behavior.



Bucket sort

Bucket sort is a divide and conquer sorting algorithm that generalizes Counting sort by partitioning an array into a finite number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. A variation of this method called the single buffered count sort is faster than quicksort.[citation needed]
Due to the fact that bucket sort must use a limited number of buckets it is best suited to be used on data sets of a limited scope. Bucket sort would be unsuitable for data that have a lot of variation, such as social security numbers.



Radix sort

Radix sort is an algorithm that sorts numbers by processing individual digits. n numbers consisting of k digits each are sorted in O(n · k) time. Radix sort can process digits of each number either starting from the least significant digit (LSD) or starting from the most significant digit (MSD). The LSD algorithm first sorts the list by the least significant digit while preserving their relative order using a stable sort. Then it sorts them by the next digit, and so on from the least significant to the most significant, ending up with a sorted list. While the LSD radix sort requires the use of a stable sort, the MSD radix sort algorithm does not (unless stable sorting is desired). In-place MSD radix sort is not stable. It is common for the counting sort algorithm to be used internally by the radix sort. Hybrid sorting approach, such as using insertion sort for small bins improves performance of radix sort significantly.



Distribution sort

Distribution sort refers to any sorting algorithm where data are distributed from their input to multiple intermediate structures which are then gathered and placed on the output. For example, both bucket sort and flashsort are distribution based sorting algorithms.



Timsort

Timsort finds runs in the data, creates runs with insertion sort if necessary, and then uses merge sort to create the final sorted list. It has the same complexity (O(nlogn)) in the average and worst cases, but with pre-sorted data it goes down to O(n).



Memory usage patterns and index sorting

When the size of the array to be sorted approaches or exceeds the available primary memory, so that (much slower) disk or swap space must be employed, the memory usage pattern of a sorting algorithm becomes important, and an algorithm that might have been fairly efficient when the array fit easily in RAM may become impractical. In this scenario, the total number of comparisons becomes (relatively) less important, and the number of times sections of memory must be copied or swapped to and from the disk can dominate the performance characteristics of an algorithm. Thus, the number of passes and the localization of comparisons can be more important than the raw number of comparisons, since comparisons of nearby elements to one another happen at system bus speed (or, with caching, even at CPU speed), which, compared to disk speed, is virtually instantaneous.
For example, the popular recursive quicksort algorithm provides quite reasonable performance with adequate RAM, but due to the recursive way that it copies portions of the array it becomes much less practical when the array does not fit in RAM, because it may cause a number of slow copy or move operations to and from disk. In that scenario, another algorithm may be preferable even if it requires more total comparisons.
One way to work around this problem, which works well when complex records (such as in a relational database) are being sorted by a relatively small key field, is to create an index into the array and then sort the index, rather than the entire array. (A sorted version of the entire array can then be produced with one pass, reading from the index, but often even that is unnecessary, as having the sorted index is adequate.) Because the index is much smaller than the entire array, it may fit easily in memory where the entire array would not, effectively eliminating the disk-swapping problem. This procedure is sometimes called "tag sort".[17]
Another technique for overcoming the memory-size problem is to combine two algorithms in a way that takes advantages of the strength of each to improve overall performance. For instance, the array might be subdivided into chunks of a size that will fit easily in RAM (say, a few thousand elements), the chunks sorted using an efficient algorithm (such as quicksort or heapsort), and the results merged as per mergesort. This is less efficient than just doing mergesort in the first place, but it requires less physical RAM (to be practical) than a full quicksort on the whole array.
Techniques can also be combined. For sorting very large sets of data that vastly exceed system memory, even the index may need to be sorted using an algorithm or combination of algorithms designed to perform reasonably with virtual memory, i.e., to reduce the amount of swapping required.
Some other sorting algorithms also i.e. New friends sort algorithm, Relative split and concatenate sort etc