What is the practical usage of /etc/networks
file? As I understand, one can give names to networks in this file. For example:
root@fw-test:~# cat /etc/networks
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0
google-dns 8.8.4.4
root@fw-test:~#
However, if I try to use this network name for example in ip
utility, it does not work:
root@fw-test:~# ip route add google-dns via 104.236.63.1 dev eth0
Error: an inet prefix is expected rather than "google-dns".
root@fw-test:~# ip route add 8.8.4.4 via 104.236.64.1 dev eth0
root@fw-test:~#
What is the practical usage of /etc/networks
file?
As written in the manual page, the /etc/networks
file is to describe symbolic names for networks. With network, it is meant the network address with tailing .0
at the end. Only simple Class A, B or C networks are supported.
In your example the google-dns
entry is wrong. It's not a A,B or C network. It's an ip-address-hostname-relationship therefore it belongs to /etc/hosts
. Actually the default
entry is also not conformant.
Lets imagine you have an ip address 192.168.1.5
from your corporate network. An entry in /etc/network
could then be:
corpname 192.168.1.0
When using utilities like route
or netstat
, those networks are translated (if you don't suppress resolution with the -n
flag). A routing table could then look like:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
corpname * 255.255.255.0 U 0 0 0 eth0
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments