[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ezjail] [PATCH] "Locally configured IP" check in ezjail-admin is not 100% reliable



On 14.01.2012 20:55, Dirk Engling wrote:
> On 14.01.12 18:59, Thomas Steen Rasmussen wrote:
>
>> The patch below changes ezjail-admin to parse the
>> output of ifconfig instead of using ping to determine if an
>> ip address is locally configured. This will also work even if a
>> firewall is blocking pings to the IP address in question.
> Hello,
>
> thanks for the patch. I had something similar in place before, but I
> hesitate parsing userland tools' output as it is not standardized and
> may be subject to changes. I'd then have a hard time handling version
> differences. Also ... see your other mail for examples of parsing
> outputs to go wrong.
Hello,

I agree, parsing the output of userland tools is not optimal.

I couldn't come up with anything better, so I asked on IRC
and xi on #bsdports came up with this clever idea:

----------------------------------------------------
[tykling@tykburk ~]$ nc -n -s 10.10.1.115 -u -w 0 127.0.0.1 1 2> /dev/null
[tykling@tykburk ~]$ echo $?
0
[tykling@tykburk ~]$ nc -n -s 10.10.1.116 -u -w 0 127.0.0.1 1 2> /dev/null
[tykling@tykburk ~]$ echo $?
1
[tykling@tykburk ~]$
----------------------------------------------------

This solves the problem in a very nice way IMO.


Best regards,

Thomas Steen Rasmussen