Monthly Archives: November 2015

Broadcast address

IP

The broadcast address for an IPv4 host can be obtained by performing a bitwise OR operation between the bit complement of the subnet mask and the host’s IP address. In other words, take the host’s IP address, and set to ‘1’ any bit positions which hold a ‘0’ in the subnet mask.

Example: For broadcasting a packet to an entire IPv4 subnet using the private IP address space 172.16.0.0/12, which has the subnet mask 255.240.0.0, the broadcast address is 172.16.0.0 | 0.15.255.255 = 172.31.255.255.

255.240.0.0=11111111.11110000.00000000.00000000
172.16.0.0=10101100.00010000.00000000.00000000
10101100.00011111.11111111.11111111=172.31.255.255

Ethernet

Broadcast is possible also on the underlying Data Link Layer in Ethernet networks. Frames are addressed to reach every computer on a given LAN segment if they are addressed to MAC address FF:FF:FF:FF:FF:FF. Ethernet frames that contain IP broadcast packages are usually sent to this address.

References :

https://en.wikipedia.org/wiki/Broadcast_address

colorama – Python Package

Description:
Cross-platform colored terminal text

Available formatting constants are:

Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL

Example :

from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

 

References :
https://pypi.python.org/pypi/colorama
http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python

How to set up a local SOCKS proxy that tunnels traffic through SSH

ssh -D 1337 -f -C -q -N user@remote -p 22
  • -D 1337 tells ssh to launch a SOCKS server on port 1337 locally.
  • -f forks the process into the background.
  • -C Turns on compression.
  • -q enables “Quiet mode”, since the purpose here is only to tunnel we don’t really care about error output and such.
  • -N tells ssh that no commands will be sent (-f complains if we don’t specify this).
  • -p specifies what port to use; obviously this is defaulted to 22 so the statement above is pointless, but if you’re a clever fellow you’re probably not running SSH on port 22 🙂

References :
http://askubuntu.com/questions/469582/how-do-i-set-up-a-local-socks-proxy-that-tunnels-traffic-through-ssh