Network topology with graphviz – Task 2.

Posted on March 20, 2012

1



Task 2.
List the interface name, the network address and the IP Address and the the DNS suffix.

IPSO Firewall ‘clish -c “show route direct”‘ output (filename: fw_direct_routes_firewall1.txt):

C     127.0.0.1/32     is directly connected, loop0c0
C     10.10.10.0/29    is directly connected, ae1c0
C     20.20.20.0/28    is directly connected, ae2c1
C     80.80.80.0/28    is directly connected, ae3c1

.

# awk -v myhostname="firewall1" '{print $6, $2, myhostname}' fw_direct_routes_firewall1.txt > fw_direct_routes_formatted_firewall1.txt

Output:

loop0c0 127.0.0.1/32 firewall1
ae1c0 10.10.10.0/29 firewall1
ae2c1 20.20.20.0/28 firewall1
ae3c1 80.80.80.0/28 firewall1

The “JOIN” Command:

# awk 'FNR==NR{myarray[$1]=$2 FS $3;next}{ print $0, myarray[$1]}' fw_ifname_ip_def_dom_firewall1.txt fw_direct_routes_formatted_firewall1.txt > fw_ifname_ip_def_dom_net_firewall1.txt

Output:

loop0c0 127.0.0.1/32 firewall1 127.0.0.1
ae1c0 10.10.10.0/29 firewall1 10.10.10.1 internal
ae2c1 20.20.20.0/28 firewall1 20.20.20.21 dmz1
ae3c1 80.80.80.0/28 firewall1 80.80.80.21 dmz2

Help:

FNR is the NR ofthe opened file. If a new file is opened it starts again from 1.
NR is the Number of Record. It runs till the last record of the last file.

# awk '{print FNR, NR, $0}' fw_ifname_ip_def_dom_firewall1.txt fw_direct_routes_formatted_firewall1.txt
1 1 ae1c0 10.10.10.1 internal
2 2 ae2c1 20.20.20.21 dmz1
3 3 ae3c1 80.80.80.1 dmz2
4 4 loop0c0 127.0.0.1
1 5 loop0c0 127.0.0.1/32 firewall1
2 6 ae1c0 10.10.10.0/29 firewall1
3 7 ae2c1 20.20.20.0/28 firewall1
4 8 ae3c1 80.80.80.0/28 firewall1

In case you have more the one firewall and they have interface on the same network, it is worth to collect this list in one file:

# cat fw_ifname_ip_def_dom_net_firewall1.txt >> fw_ifname_ip_def_dom_net_all.txt
Advertisements