LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2016, 07:08 AM   #1
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Rep: Reputation: 57
Command line to show default gateway assigned to a network interface by DHCP


When network adapter eth0 is given an IP and a default gateway by DHCP, what is the command to show what default gateway has been given to it?

Ideally without regard to the routing table, in other words even if you have cleared the routing table, if possible?
 
Old 07-16-2016, 07:29 AM   #2
af7567
Member
 
Registered: Nov 2012
Posts: 291

Rep: Reputation: 104Reputation: 104
That depends on what DHCP client your system is using, and where it logs messages. In Slackware I can find the route provided by the DHCP server by doing

Code:
# fgrep "dhcpcd" /var/log/messages
If your system uses dhclient instead of dhcpcd then try replacing "dhcpcd" with "dhclient".
 
Old 07-16-2016, 10:31 AM   #3
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
It's dhclient here, in /var/log/syslog. But the line that shows 192.168.0.1 does not mention eth0. Eth0 only appears here:

DHCPREQUEST of 192.168.0.103 on eth0 to 255.255.255.255 port 67 (xid=0x1031eb9d)

Any other ideas?
 
Old 07-16-2016, 10:39 AM   #4
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Maybe these 3 lines can be parsed as one?

NetworkManager[1155]: <info> (eth0): DHCPv4 state changed preinit -> reboot
NetworkManager[1155]: <info> address 192.168.0.103
NetworkManager[1155]: <info> prefix 24 (255.255.255.0)
NetworkManager[1155]: <info> gateway 192.168.0.1

Last edited by Ulysses_; 07-16-2016 at 10:41 AM.
 
Old 07-17-2016, 06:19 PM   #5
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
Try this:
Quote:
ip route show
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting the default gateway ip address on my interface from (DHCP provided) ISP crackyblue Linux - Networking 1 05-04-2011 03:02 AM
how can i restrict access to my network to only dhcp assigned ip's? lukesaber Linux - Security 7 03-02-2011 06:18 AM
Default gateway not being set when using DHCP ret602 Linux - Networking 1 09-20-2007 12:17 PM
Adding Network Interface alias from command line WireLine Fedora 2 06-08-2005 11:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration