Getting info from ifconfig output

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

 



Browsing the list I saw a question regarding using grep and friends
to get an IP. I do this, but to allow a single firewall config file to
be used on a number of machines without editing. Here are the first few
lines, I hope they are useful to someone. I extract the IP and the
broadcast (I don't always have 8 bit subnetting).


# define internal and external interfaces
int_i=eth0
ext_i=eth1
loopback=lo

# define the IP of the external address, only IP used
AdrsLine=$(ifconfig ${ext_i} | grep "inet addr:")
ext_ip=$(expr "$AdrsLine" : ".*inet addr: *\([0-9.]*\)")
Bcast=$(expr "$AdrsLine" : ".*Bcast: *\([0-9.]*\)")

-- 
bill davidsen (davidsen@xxxxxxx)
Doing interesting things with small computers since 1979.


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux