Cfengine gives the address on the interface, like in the following from my host.
There are too many possibilities to document in the manual -- each interface 
can have
a different name/address etc

$(sys.ipv4)      192.168.1.100

$(sys.ipv4[wlan0])       192.168.1.100

$(sys.ipv4_1[wlan0])     192
$(sys.ipv4_2[wlan0])     192.168
$(sys.ipv4_3[wlan0])     192.168.1


高永超 wrote:
> Er...It's my fault not explaining my demands clearly...
> I want to use cfengine3 to set my hostname which contains a part of the
> ip address...
> The only way i can find is using shell script to "grep" it from the
> output of "ifconfig", and someone tells me in cfengine2 there is a
> builtin variable so i want to know if there is also a simple way in
> cfengine3?
> 
> 2009/12/16 Andreas Dan Larsson <andreas.d.lars...@axis.com
> <mailto:andreas.d.lars...@axis.com>>
> 
> 
>     > HI, everyone, is there a way to get local ip address in cfengine3?
> 
>     Hi,
> 
>     You could use the builtin variable for hostname $(sys.fqhost) and
>     use that to get the ip from you nameservice
> 
>     Perhaps something in the lines of:
> 
>     "ip" string => execresult("host $(sys.fqhost) | sed -ne
>     's/$(sys.fqhost) has address ([.0-9]+)/\1/p' ","useshell")
> 
>     This ofcourse only works if you can resolv the host in dns. Im sure
>     others will object if this is a inappropriate method for determining
>     ip address. :)
> 
>     /Andreas Larsson
> 
> 
> 
> 
> 
> 
> -- 
> SA,专注于系统管理
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Mark Burgess

-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway

Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to