[Gllug] "ip" command

Nix nix at esperi.org.uk
Sat Feb 4 23:48:35 UTC 2006


On Fri, 3 Feb 2006, Russell Howe stated:
> On Fri, Feb 03, 2006 at 01:45:01PM +0000, Bruce Richardson wrote:
>> On Fri, Feb 03, 2006 at 01:17:56PM +0000, Richard wrote:
>> > 
>> > Anyone know what the "ip" command is?
>> 
>> It's a networking swiss army knife.  Does the job of ifconfig and route
>> (much more flexibily than either) and a range of other things like
>> policy routing.  Indispensible tool for me.

Quite so. Policy routing, routing by source address, multipath routing,
routing by user ID (!), everything other than firewalling and traffic
shaping in one command :)

> Although I haven't found a way to get it to understand a dotted quad
> netmask, only CIDR notation, which led me to produce this little gem of
> shell:

Oh, lovely. Thanks, that goes straight into my dhcp config :)

> netmask_to_cidr() {
> 	echo "$1"| (
> 		IFS=.
> 		read NM1 NM2 NM3 NM4
> 
> 		NMDEC="$(((NM1 << 24) + (NM2 << 16) + (NM3 << 8) + NM4 ))"
> 
> 		if [ "$NMDEC" -gt $((0xffffffff)) -o "$NMDEC" -lt 0 ]; then

Pedant: if you have functions and $(()), you certainly have [[ ]] as
well.

-- 
`I won't make a secret of the fact that your statement/question
 sent a wave of shock and horror through us.' --- David Anderson
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list