LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 01-11-2016, 02:20 AM   #1
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Rep: Reputation: 3
resolv.conf on a read-only operating system


I am working on configuring Raspbian jessie to run as read-only. The only part of the file system that will be writable is /tmp which is mounted as tmpfs. DHCP is configured to write everything in /tmp so the system gets an IP Address from DHCP.

My problem is that the system cannot write to /etc/resolv.conf. I can ping internet IP Addresses, but not domain names. Theres no resolution.

I have created a symbolic link, pointing /etc/resolv.conf to /tmp/resolv.conf. But the issue here is that everything in /tmp is deleted on every boot. And resolv.conf is not created automatically. So theres no file for the system to write to.

I have also tried creating /tmp/resolv.conf using touch /tmp/resolv.conf in /etc/rc.local. The file gets created but theres nothing written in it. When I run dhclient manually after the system has booted, it writes to /tmp/resolv.conf and everything is fine. So I added the command dhclient in /etc/rc.local but it didnt write anything in /tmp/resolv.conf

Im kind of lost here. I need a tidy, proper way of moving resolv.conf to /tmp

Last edited by aristosv; 01-11-2016 at 02:21 AM.
 
Old 01-11-2016, 08:45 AM   #2
pingu_penguin
Member
 
Registered: Aug 2004
Location: pune
Distribution: Slackware
Posts: 350

Rep: Reputation: 60
If your nameservers are not going to change , then perhaps you could try adding the following to /etc/rc.local :

# echo "nameserver x.x.x.x" > /tmp/resolv.conf
# echo "nameserver y.y.y.y" >> /tmp/resolv.conf

where x.x.x.x and y.y.y.y and the nameservers required.

hope this helps.

Also , Is your Raspbian Jessie getting only an IP via dhcp and not the nameservers ? posting your rc.local could help a bit too.

Regards,
pingu.
 
Old 01-11-2016, 08:55 AM   #3
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Original Poster
Rep: Reputation: 3
The name servers are going to be changing.

IP and DNS information all exist in /etc/network/interfaces. But unless /etc/resolv.conf has the DNS information, I don't have internet access.
 
Old 01-11-2016, 09:07 AM   #4
pingu_penguin
Member
 
Registered: Aug 2004
Location: pune
Distribution: Slackware
Posts: 350

Rep: Reputation: 60
In that case you could add the following to your /etc/network/interfaces file :

auto eth0
iface eth0 inet dhcp

where I presume eth0 is the nic in your device.
 
Old 01-11-2016, 09:19 AM   #5
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Original Poster
Rep: Reputation: 3
Maybe I wasn't clear.
The system gets an IP Address from DHCP. That part is working OK.
The problem is with resolv.conf not containing any DNS server entries, because the file system is read-only.
So I need to somehow move /etc/resolv.conf to /tmp which is writeable, but emptied on each reboot.
 
Old 01-11-2016, 10:00 AM   #6
pingu_penguin
Member
 
Registered: Aug 2004
Location: pune
Distribution: Slackware
Posts: 350

Rep: Reputation: 60
Hi,

Sorry for the confusion.

The dhclient command invokes the /sbin/dhclient-script from time to time (man dhclient-script) in debian.
Perhaps you could replace the path for /etc/resolv.conf to /tmp/resolv.conf in the script and then give it a try.

ie.
1.modify the /sbin/dhclient-script script.
2. modify /etc/rc.local to contain the following (order matters obv.) :
# touch /tmp/resolv.conf
# dhclient <interface>

Make sure you backup the /sbin/dhclient-script script to a safe place before modifying it.

Hope this helps.

Regards,
pingu.
 
Old 01-12-2016, 02:26 AM   #7
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Original Poster
Rep: Reputation: 3
Modifying dhclient-script did it. Thank you.
 
  


Reply



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
Read these two books together to learn Operating System. Is that helpful? mirage1993 Linux - Newbie 2 02-28-2014 12:18 AM
Which GNU/Linux operating system should I use? Read more for details. nuxxun Linux - Newbie 8 12-31-2013 11:18 AM
Two topics (File System Access & resolv.conf) qs_tahmeed Solaris / OpenSolaris 6 02-10-2006 09:47 PM
where does system-config-network put dns info, besides /etc/resolv.conf ? bdp Fedora 1 09-03-2004 12:09 AM
Re-read resolv.conf klnasveschuk Linux - Networking 2 07-14-2003 06:59 AM

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

All times are GMT -5. The time now is 08:23 AM.

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