OpenWrt Forum Archive

Topic: How to get IP/DNS information with dynamic settings?

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

If I set the router to get IP dynamically via WAN port, what command can I use to get such information about the IP, DNS, GW (e.g. from the ISP)? I listed all packages but did not see any DHCP client package listed. Is that built in somehow in the box?

Thank you.

If you follow the network startup scripts through you will see that if the interface variables are set to dhcp then the "udhcpc" command is called to configure your interface.

Thank you,

Can you let me know where I can find the network scripts? Actually I am quite new to this router and I just use White Russian RC2 (squash image) and after rebooting I telnet in and now ssh-in. Is there anyway I can see how the network script starts/stop etc? I do not have serial port, just the router from the shop.

The startup scripts reside in the /etc/init.d directory. If you look at the S40network script you should find the command that brings up the "wan" interface:

ifup wan

The "ifup" command is actually a script. Take a look at /sbin/ifup. In that script you will see where it parses the nvram variables and when it comes across "wan_proto" you'll see a section that gets executed when an interface is set to dhcp. This is where the call to "udhcp" is.

If you just want to view your gateway and ip address information you can use a few commands like "ifconfig", "ip", and "netstat". For instance, "netstat -rn" will show you your routing table. "ifconfig" will list all the interfaces and their currently configured ip address information. The "ip" command can also show you various IP information about your interface(s). "ip addr" and "ip route" will show you somewhat similar information.

Your DNS server information goes in /etc/resolv.conf. If configured by DHCP you will find a /tmp/resolv.conf. You might want to symbolic link /etc/resolv.conf to /tmp/resolv.conf if you want to use your provider's DNS servers for resolution.

The discussion might have continued from here.