Assume eth0 is DHCP client interface.
One of optionsoption is to check the DHCP client lease files dhcpd.leases
Place and name dependdepends on system,the system; on some fedora boxFedora systems, the files under /var/lib/dhclient/ areare lease files, where the interesting string is like that :
option routers 192.168.1.1;
Another option, which worked for me on a funtoo box: dhcpcd -U eth0dhcpcd -U eth0
prints a nice table, ready to source in scripts
broadcast_address=192.168.1.255
dhcp_lease_time=86400
dhcp_message_type=5
dhcp_server_identifier=192.168.1.1
domain_name_servers='192.168.1.1 192.168.1.101'
ip_address=192.168.1.101
network_number=192.168.1.0
routers=192.168.1.1
subnet_cidr=24
subnet_mask=255.255.255.0
There also anotherother options like dhcpingdhcping, dhclient -ndhclient -n, according to google and manpages, but they failsfail on my boxes, but may work for you.