#!/bin/sh belongs_network () { addr=$1 network=$2 netaddr=`echo $network | cut -d / -f 1` netcdr=`echo $network | cut -d / -f 2` a1=$(echo "$addr" | cut -d . -f 1) a2=$(echo "$addr" | cut -d . -f 2) a3=$(echo "$addr" | cut -d . -f 3) a4=$(echo "$addr" | cut -d . -f 4) n1=$(echo "$netaddr" | cut -d . -f 1) n2=$(echo "$netaddr" | cut -d . -f 2) n3=$(echo "$netaddr" | cut -d . -f 3) n4=$(echo "$netaddr" | cut -d . -f 4) ares=$((($a1*256*256*256+$a2*256*256+$a3*256+$a4)>>(32-$netcdr))) nres=$((($n1*256*256*256+$n2*256*256+$n3*256+$n4)>>(32-$netcdr))) if [ $ares -eq $nres ] ; then return 0 else return 1 fi } if belongs_network 10.208.103.255 10.208.128.0/17; then echo "belongs" else echo "does not belong" fi
пятница, 13 октября 2017 г.
Does ip belong to network?
It's so easy to check if IP belong to network... Until you start doing this in shell. I've tried and finally got this. This version works in bash, dash and ksh...
Good enough for me, but perhaps it could be optimized a bit to avoid cut usage.
Our function gets two parameters - ip address and network in address/netmask format. In fact we compare IPaddress & netmask and IPnetwork & netmask.
среда, 29 марта 2017 г.
Thank you, Oracle engineers
After 2010, when Oracle acquired Sun, most of us, who followed OpenSolaris, were depressed. In one year one of the most advantageous operating systems was closed under steel curtain. Luckily, due to enormous efforts of community, of companies, dependent on OpenSolaris, the system survived. Currently we have several more or less successful illumos distributions, targeting different users.
But nowadays there's a (of course, deserved) common negative feeling towards Oracle in illumos community. But let's speak from another point of view. Let's look at things, which illumos community (and in particular, OpenIndiana) got directly or indirectly from Oracle in recent years.
- Our userland build system, which constantly evolves, however, in different directions, under Oracle control and in our distribution. But still a lot of components can be easily migrated between build systems.
- A lot of software build receipts and patches, as result, were borrowed with small modifications, from Oracle userland-gate. The process is still going on.
- We still borrow patches from Solaris pkg-gate. Also differences in underlying kernels are currently rather significant, a lot of changesets from pkg-gate can be ported to OpenIndiana pkg5 repository.
- Of course, I can not avoid thanking Alan for his constant help in supporting Xorg subsystem and GUI parts of our distribution. He was always helpful to me and Aurélien.
- Evidently, recent KMS work, integrated into OpenIndiana, wouldn't be possible without Oracle's open drm port, which was ported from Solaris to illumos by Martin Bochnig, and later independently ported and enhanced by Gordon Ross.
четверг, 16 февраля 2017 г.
Enterprise Information systems
This year I'm going to read "Enterprise Information systems" course for students of Southern Federal University Institute for Advanced Technologies and Piezotechnics.
The materials of this course will be appearring in this Microsoft Class Notebook
Google docs link
Подписаться на:
Сообщения (Atom)