I needed a TFTP/PXE server at home so that I can continue development of Barrelfish under the same conditions that I have at work. This document is a rough outline of the steps I took to complete this goal.
This document is the second in my setup of a TFTP/PXE boot sever based off of Ubuntu 10.4. You should read my previous post on removing Network-Manager if you have this application installed and are using it for wireless and wired network administration. Before proceeding you need to remove this and other automatic network utilities before proceeding, even if you didn't use them for wireless network administration. Please see Removing Network-Manager And Manually Administering Wireless Connections In Linux for more information.
The network adapter that is facing your local network will be referred to in this document as LAN0, on my machine this will translate to eth0 and WLAN1 will correlate to my eth1. The may and likely will vary to your setup so please substitute as appropriate.
I will try to append links at the end of this document in the order in which they were used. Some of the links I used several times and in different sections but I'm too lazy to point at each spot of each source so this I feel is better than nothing.
Make a backup of /etc/network/interfaces. Edit the source file with your favorite editor. Replace entries relevant to LAN0 with the following, else just append.
auto LAN0 iface LAN0 inet static address 10.1.84.1 network 10.1.84.0 netmask 255.255.255.0 broadcast 10.1.84.255
Remember to replace LAN0 with your interface.
The base address 10.1.84.x was selected somewhat arbitrary, I just wanted a base address that I could recognize as coming from me. 10.0.0.x seems to be common as do 192.168.1.x so I was just trying to avoid the common bases.
Restart networking,
# sudo /etc/init.d/networking restart
Run an ifconfig, make sure LAN0 received the new settings and that WLAN1 was unaffected, additionally confirm that you can still connect to the internet/external network. Plug LAN0 into the wired network and insure that other computers and the server are still unaffected.
Install DNSMasq,
# sudo apt-get install dnsmasq
Make a backup copy of /etc/dnsmasq.conf
Find the first occurrence of dhcp-range and, uncomment this line and edit the current value so that it looks like,
dhcp-range=10.1.84.100,10.1.84.200,12h
Additionally uncomment the first occurrence of interface and specify the LAN0 interface as we don't want to cause trouble on other networks.
interface=LAN0
Now, restart dnsmasq
# sudo /etc/init.d/dnsmasq restart
If everything went correct, you should see no error messages.
Renew the ip address on another computer on the internal network, if this is a linux machine you can do so by issuing the following.
# sudo dhclient -r <interface> # sudo dhclient <interface>
The above code releases any already obtained IP address and requests a new one.
Running ifconfig should reflect an address in the range given above. If not there is a problem. Check all your wires first and work back.
Issue the following commands,
# iptables -A FORWARD -i eth0 -s 10.1.84.0/255.255.255.0 -j ACCEPT # iptables -A FORWARD -i eth1 -d 10.1.84.0/255.255.255.0 -j ACCEPT # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # echo 1 > /proc/sys/net/ipv4/ip_forward
These settings will be reset after we restart our computer so lets make them more permanent.
First, open /etc/sysctl.conf with your favorite text editor and uncomment net.ipv4.ip_forward=1.
Export the changes to iptables,
iptables-save > /etc/iptables.rules
Make sure this output file is not empty before continuing!
Then, edit /etc/network/interfaces and include the following two lines under the LAN0 heading
pre-up iptables-restore < /etc/iptables.rules #post-down iptables-restore < /etc/iptables.downrules
The commented line is there just to remind me how, if I ever needed it, to apply a down script. The first line restores the ip tables.
Here is my complete interfaces file,
auto lo iface lo inet loopback # Wireless Network Configuration see node 15 on paretech.com for details auto eth1 iface eth1 inet dhcp wpa-conf /etc/wpa_supplicant.conf # Wired Network Configuration see node 16 on paretech.com for details auto eth0 iface eth0 inet static pre-up iptables-restore < /etc/iptables.rules # post-down iptables-restore < /etc/iptables.downrules address 10.1.84.1 network 10.1.84.0 netmask 255.255.255.0 broadcast 10.1.84.255
Now would be a good time to test to make sure everything comes up out of a restart.
Well I'm back so the settings were properly restored.
Now we want our new server to control host names and to associate/point them to the ip addresses. This will make our lives much simpler as we will not have to keep up with so many numbers and we can name elements in our network logically.
With your favorite text editor open /etc/hosts.
Near the top of the file there should be a line like,
127.0.1.1 <host-name>
Additionally, if you want any static ip devices on this network go ahead and declare them here, but we will also need to do something special for those in dnsmasq.conf so keep this information handy.
Go ahead and open /etc/dnsmasq.conf and add entries for the computers you want statically mapped. Here is a copy of a few entries of mine.
# Send extra options which are tagged as "red" to # the machine with ethernet address 11:22:33:44:55:66 #dhcp-host=11:22:33:44:55:66,net:red dhcp-host=00:0F:B0:8C:15:38,barrel,barrel,7200m,net:known dhcp-host=00:17:42:BF:43:5E,sandia,sandia,7200m,net:known dhcp-host=00:24:8C:A8:59:07,fish1,fish1,7200m,net:known,net:grub
Additionally uncomment the line, dhcp-ignore=#known
We will use the known net to assign a response when a connections is not known, therefore an IP address will only be assigned to known clients.
Change 127.0.1.1 to the ip address you set for the LAN0 interface in /etc/network/interfaces.
Open /etc/dnsmasq.conf with your favorite text editor. Uncomment the following lines,
enable-tftp
Add the following to dnsmasq.conf, after #dhcp-boot=pxelinux.0, dhcp-boot=net:barrelfish,barrelfish_grub
Of course, barrelfish_grub is specific to my project so configure as needed.
Additionally, add the following to dnsmasq.conf after #dhcp-option-force=210,/tftpboot/pxelinux/files/, dhcp-option-force=210,/tftpboot/
And finally, add the following to dnsmasq.conf after #tftp-root=/var/ftpd, tftp-root=/tftpboot
Comments
I Made A Post In Forums
I made a post in forums which might be helpful for those trying to debug their system, http://ubuntuforums.org/showthread.php?t=1503710
Post new comment