Showing posts with label tomato. Show all posts
Showing posts with label tomato. Show all posts

Saturday, January 24, 2009

Send Hostname to Router

I have Tomato firmware on my Linksys WRT-54GL wireless router. I purchased the router so I could put Tomato or another open source firmware version.

One of the things that I wanted with this was to assign the same ip address to each computer through DHCP and get my internal DNS working without setting up bind. The tool that performs this duty and comes with most of these firmwares is Dnsmasq. It's a very easy to setup DNS and DHCP server.

The Tomato web interface makes it easy to assign an ip address to the specific MAC address of the ethernet or wireless network card. If the machine has one interface this isn't a problem. This becomes an issue for laptops that connect either via the wireless card or the ethernet cable. The problem is that Dnsmaq (and most other DHCP software) will not allow the same ip address to be assigned to two different mac addresses.

Most DHCP clients have the ability to send a hostname so that the DHCP server can assign a specific address to the machine everytime no matter the interface being used. This prevents tying the ip address to a specific MAC addresss. This ability is easy to enable in the Dnsmasq interface in Tomato.

Go to the Advanced -> DHCP/DNS. Enter the following in the custom configuration section:
dhcp-host=MyHostname.domain.what, 192.168.xx.xx

Change the information to be what you want it to be for your internal network. I don't use a "domain.com" or "domain.anything" that is could be a real domain name.

In Windows, change the computer name to match "MyHostname" and reboot. After rebooting, go to Start -> Run -> type cmd and click Run. A command window should have appeared. Type ipconfig[ENTER] to see the IP Address assigned. I had no problem setting this up in Windows.

Under Fedora 10, I ran into more difficulty. I used the normal Network Admin tools to attempt to set the "DHCP-Hostname". After starting the interfaces a few dozen times, I was never able to get the IP assigned in this manner.

NetworkManager is used to control the interfaces on the laptops. If it used to edit the connection information, there is an option on the IPv4 Settings tab for DHCP Client ID. This is not the same as sending the hostname.

In the man page for dhclient.conf, there's an option for sending the hostname:
send host-name "MyHostname.domain.what";

The problem is that NetworkManager does not read the file called /etc/dhclient.conf. NetworkManager generates it's own .conf file to pass to dhclient. Finally I came across a post that mentioned creating a file called /etc/dhclient-ifname.conf. In my case, the files are called:
/etc/dhclient-eth0.conf
/etc/dhclient-wlan0.conf

I placed the above configuration option for sending the hostname into these files and restarted NetworkManager. NetworkManager or the dhclient program picked up these file for the interface and sent the host-name. So it works for me now.

This is what's in my /etc/dnsmasq.conf file on the router:

interface=br0
domain=doman.internal
resolv-file=/etc/resolv.dnsmasq
addn-hosts=/etc/hosts.dnsmasq
expand-hosts
min-port=4096
dhcp-range=192.168.xx.mm,192.168.xx.rr,255.255.255.0,1440m
dhcp-option=3,192.168.99.2
dhcp-authoritative
dhcp-host=00:15:C5:BB:37:3C,192.168.xx.aa,1440m
dhcp-host=00:0B:82:04:03:E7,192.168.xx.bb,1440m
dhcp-host=00:04:F2:02:27:62,192.168.xx.cc,1440m
dhcp-host=MyHostname.domain.internal,192.168.xx.hh


If you don't want to maintain a /etc/hosts file on all of your machines, ssh into the router and edit the /etc/hosts file. Any ip and name pair will resolve when doing the following from the command line:
host machine-name

The /etc/hosts/file looks like this: This doesn't work

192.168.xx.aa MyHostname
192.168.xx.bb AnotherHostname



Update: Modifying the /etc/hosts files directly doesn't work. This post describes what you need to do. Go to Basic ->Static DHCP and add an entry. Don't fill out a mac address.

Update: Added a semi-colon to the send host-name line.

Sunday, July 13, 2008

Tomato Firmware

After listening to the discussion regarding wireless routers n the TWUUG list, I finally decided to buy a WRT54GL. About 4 years ago I purchased a Linksys WRT54GS v1.1 with the intention of replacing it's bios with one of the custom firmware releases. I never got around to it and I didn't want to brick my only router. So I bought the WRTG54L since it's the only one of the WRT54G/GS models that you can put Linux on now. All of the others have limited memory and only run VxWorks.

I installed OpenWRT. It installed without a problem. I wanted a nice webgui, but the latest didn't have one or I didn't find it. Instead, I used Tomato.

Tomato's webgui is nice. I set it up within a few minutes and replaced the old router with the new. The network statistics are cool. It provides a realtime graph that can be viewed in the browser and it maintains a daily, weekly, and monthly log.

I've turned on QOS, but I don't know how well it is working. This week should give me an idea of how well the QOS works. I set my Vonage voip device to have the highest settings.

I need the extra router for a trip to the beach later this month. After that I'll play around with OpenWRT. There are some interesting things that can run on the router. I want to play around with Asterisk. I've got some actual voip phones that I can use.