Skip to content

Instantly share code, notes, and snippets.

View danish-rehman's full-sized avatar

danish-rehman

View GitHub Profile
@danish-rehman
danish-rehman / delete_routes
Created January 9, 2015 18:45
Delete entries from the routing table
# Delete lan0 entry
>> sudo route del -net 10.0.0.0 netmask 255.0.0.0
# Delete the lan1 entry
>> sudo route del -net 10.1.2.0 netmask 255.255.255.0
# Delete the link to rtr2
>> sudo route del -net 10.10.3.0 netmask 255.255.255.0
# Delete the link to rtr1
@danish-rehman
danish-rehman / firewall_rule
Created January 9, 2015 18:43
Firewall rule unreachable
>> sudo iptables -I OUTPUT -p icmp --icmp-type destination-unreachable -j DROP
@danish-rehman
danish-rehman / tcp_keepalive_probes
Created January 9, 2015 17:49
TCP_KEEPALIVE_PROBES
>> echo 5 > /proc/sys/net/ipv4/tcp_keepalive_probes
@danish-rehman
danish-rehman / tcp_keepalive_interval
Created January 9, 2015 17:47
TCP_KEEPALIVE_INTERVAL
>> echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl
@danish-rehman
danish-rehman / fin_timeout
Created January 9, 2015 17:44
TCP fin timeout
>> cat /proc/sys/net/ipv4/tcp_fin_timeout
60 seconds
# To change the value
>> echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
@danish-rehman
danish-rehman / change_window_socket
Created January 9, 2015 08:15
Change TCP window size from socket
# SO_SNDBUF
# Cannot exceed maximum size available in kernel config
# Kernel config: /proc/sys/net/core/rmem_max
212992
# SO_RCVBUF
# Cannot exceed maximum size available in kernel config
# kernel config: /proc/sys/net/core/wmem_max
212992
@danish-rehman
danish-rehman / change_window_size
Created January 9, 2015 07:37
Change TCP window size
# Current receiver window size (12Mb)
>> sudo su
>> echo 'net.ipv4.tcp_rmem= 4096 87380 12582912' >> /etc/sysctl.conf
>> sysctl -p
# Current sender window size (12Mb)
>> sudo su
>> echo 'net.ipv4.tcp_rmem= 4096 87380 12582912' >> /etc/sysctl.conf
>> sysctl -p
@danish-rehman
danish-rehman / view_window
Created January 9, 2015 07:22
See the values of TCP window
# current receiver window size
>> sysctl -n net.ipv4.tcp_rmem
4096 87380 2063584 (2Mb)
# current sender window size
>> sysctl -n net.ipv4.tcp_wmem
4096 87380 2063584 (2Mb)
# maximum segment size
>> sysctl -n net.ipv4.tcp_app_win
@danish-rehman
danish-rehman / tcp_send_recv
Created January 9, 2015 07:12
Set send and Recieve TCP window
# (Maximum TCP Sender Window)
>> /proc/sys/net/ipv4/tcp_wmem
4096 16384 4194304
(Maximum TCP Receive Window)
>> /proc/sys/net/ipv4/tcp_rmem
4096 87380 6291456
@danish-rehman
danish-rehman / curl_cmd
Created January 9, 2015 02:58
Curl command
# Basic get request
>> curl -v http://www.test.com
# Get request with a header
>> curl -v http://www.test.com?debug=1 -H "Cookie: Key=Value;”