Linux

Create virtual / alias IP address

This is the code to make an alias IP address on network interface ethX where X is a number to indicate the device we are attaching the IP. ifconfig eth0:1 192.168.0.30 netmask 255.255.255.0 up Your machine will now answer on ping requests 192.168.0.30. You can see the result by running the command ifconfig eth0:1 Result […]

Read More
Scripting

Sort IP address

Sorting IP addresses using sort is not easy because the dot confuses sort. This line makes it possible to sort by the whole value of the address sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 ipaddresses.txt You can also sort by the last octet sort -r. -n +3.0 ipaddresses.txt

Read More
Network

Using TCP Wrappers to deny daemon access in specified hours

By doing the following you can deny certain daemons to be available in specified hours by using hosts.allow and hosts.deny. In my example I will be using the vsftpd daemon by adding tcp_wrapper=YES in /etc/vsftpd.conf. Make sure that your private network has access all the time by adding this in /etc/hosts.allow vsftpd: 192.168.0. Enables access […]

Read More
Network

nmap scanning and printers

When you plan to nmap scan a network which contains printers, avoid scanning the JetDirect port, port 9100. Newer versions of nmap skips TCP port 9100 because some printers simply print anything sent to that port, leading to dozens of pages of HTTP get requests, binary SSL session requests, etc. This behavior can be changed […]

Read More
Network

nslookup-scan of IP-range/subnet

#!/bin/bash # nslookup-scan of IP-range # It’s possible to add more networks separated with space NETS=”192.168.0″ IPRange=”1 254″ for NET in $NETS; do for n in $(seq $IPRange); do ADDR=${NET}.${n} echo “${ADDR},`nslookup ${ADDR} | awk -F “=” ‘{ print $2 }’|sed ‘s/^[ t]*//’ | sed ‘/^$/d’ | |sed ‘s/.$//’`” done done Result 192.168.0.1,cba.infra.no 192.168.0.2,bca.infra.no 192.168.0.3,abc.infra.no […]

Read More