0

when i cat the file

/etc/sysconfig/network-scripts/ifcfg-ens192

a line showing the gateway for ens192:

GATEWAY=10.2.2.2

but when i run netstat -r or route

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         gateway         0.0.0.0         UG        0 0          0 ens192
10.2.2.0        0.0.0.0         255.255.255.0   U         0 0          0 ens192
10.2.3.0        0.0.0.0         255.255.255.0   U         0 0          0 ens256

Gateway seems to be 0.0.0.0 what is the difference between the two gateway? i am so confused..

4
  • Is there another line in netstat's output that includes 10.2.2.2 ? – Mark Plotnick Sep 5 '17 at 6:36
  • @MarkPlotnick No, there isnt, ive edit to the full netstat output – once Sep 5 '17 at 7:47
  • Can you add -n to the netstat -r command? – Mark Plotnick Sep 5 '17 at 9:58
  • @Mark Plotnick, the n flag shows gateway as 10.2.2.2! thanks!! – once Sep 12 '17 at 3:24
2

You misunderstand the meaning of a gateway. You need a gateway for reaching an IP address which is not link-local.

10.2.2.0/255.255.255.0 is link-local thus you do not need a gateway for it. This entry does not show which gateway is used but which interface is used for this subnet.

2
  • so 10.2.2.2 should not appear in route or netstat -r? – once Sep 5 '17 at 7:49
  • @once I am not so familiar with route, I always use ip route. I would expect your line default gateway to be default 10.2.2.2. Maybe your entry GATEWAY=10.2.2.2 is wrong somehow and thus not accepted as default gateway. – Hauke Laging Sep 5 '17 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.