netif restart removes default destination in routing table

I was troubleshooting the gateway about internet connection. Since no one in
the local network was able to access the web. Although LAN is fine and access
to local information system has no problem.

Here are the steps I did to troubleshoot
1. ping from localnet to gateway public IP and private IP.
Result: OK
2. ssh from localnet to gateway private IP
Result: OK
3. ping from gateway to outside world via hostname.
Result: not OK
4. ping from gateway to outside world via IP Address.
Result: OK
Remarks: I was thinking that it was name resolution problems
5. Check the services (squid, isc-dhcp, dnsmasq)
Result: All running and without problems.
6. Checked the routing table,
Result: Entries are what to be expected including the default gateway
7. Restarted network via /etc/rc.d/netif restart
Result: two NICS are active and have their IPs
8. Checked the routing table,
Result: Entries are what to be expected BUT NO default gateway!
9. # route add default ***.***.***.***
10. ping http://www.google.com
result: everything was OK and back to normal, local network (clients)can now
access the web

Questions:
1. In the first part (the routing table was fine, services were OK), but
name resolution was not working.. What could have been the cause?

2. After restaring NICs and finding out that default gateway was not
in the routing table, of course, all connections was done. But when
the "route add default " was issued, all works including the name resolution?
What could be the cause?

3. How come does "netif restart" causes the removal of default gateway from the
routing table? Which makes me add it manually to make things OK.

Here is my rc.conf (I change the IPs to ***.***.***.***, but in my actual file, it contains its IP Addresses,)
Code:
gateway_enable="YES"
hostname="sample.sample.com"
ifconfig_em0="inet ***.***.***.***  netmask ***.***.***.***"
defaultrouter="***.***.***.***"
ifconfig_em1="inet ***.***.***.*** netmask ***.***.***.***"
keymap="us.iso"

fsck_y_enable="YES"
background_fsck="NO"

#Firewall
pf_enable="YES"
pf_rules="/etc/pf.conf"
pflog_enable="YES"

#Services
squid_enable="YES"
sshd_enable="YES"
ftpproxy_enable="YES"
dnsmasq_enable="YES"
dhcpd_enable="YES"
dhcpd_ifaces="em1"
 
To explain, a [cmd=]/etc/rc.d/netif restart[/cmd] will first destroy any and all IP addresses assigned to the interfaces. When that happens routes containing those subnets also get removed. This usually includes the default gateway. After the IP addresses have been removed they're get set again. Directly connected networks get added to the routing table but the default gateway needs to be set again.
 
Back
Top