Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Wednesday, June 18, 2008

And Linux is now a wireless AP router

I followed the instructions in the YoLinux article on making the Linux gateway ... and it works perfectly. The WORKIT AP now functions as a gateway router, instead of the bridge as it was earlier. (The LinuxJournal article mentioned in my previous post is a little old at this point.)

I just had to follow the instructions to set up the gateway. This is what I used for the WORKIT AP (eth0 is my wired WAN connection and ath0 is the wireless LAN):
   # Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
# Flush all the rules in filter and nat tables
iptables --flush
iptables --table nat --flush
# Delete all chains that are not in default filter and nat table
iptables --delete-chain
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface ath0 -j ACCEPT

# Enables packet forwarding by kernel
echo 1 > /proc/sys/net/ipv4/ip_forward

Also, while instructions exist for both iptables and ipchains, you will find yourself using the iptables rules since ipchains was RIP after Linux 2.4 came out.

Tuesday, June 17, 2008

Installing kernel source in Voyage Linux

While making kernel based modules, I got an error of the type:

"Missing .config file in /lib/modules/2.6.20-486-voyage/build"

The reason this happens is because the kernel source is not installed with Voyage Linux, but if you are building kernel modules, you need access to this.

apt-get install kernel-sources does not work either.

What I did was:
  1. Download the corresponding kernel source version from the Linux kernel archives.
  2. Untar to /lib/modules/2.6.20-486-voyage/build
  3. Run "make config"
  4. Make sure to turn on "kernel support for .config files" (turned off by default, this is one of the first few options)
Now, you have a fully functioning kernel source tree in your Voyage Linux installation so you can compile kernel modules.

UPDATE, June 25, 2008: From a forum post, I found that you can actually find the source code for the Voyage Linux 0.4 kernel from their website at : http://www.voyage.hk/dists/0.4/linux/.

Actually, it looks like most of their distros have source online as well. Just replace "0.4" in the above link with your distribution number and expect to find your source tarball there.

Friday, June 13, 2008

dnsmasq now working as DHCP server as well

Now I have dnsmasq working as a DHCP server as well.

In my configuration, I added the following lines:

dhcp-range=ath0,10.0.0.10,10.0.0.250,24h
dhcp-leasefile=/var/tmp/dnsmasq.leases
dhcp-authoritative
# Gateway
dhcp-option=3,10.0.0.1
# DNS
dhcp-option=6,10.0.0.1

and dnsmasq is now able to serve up DHCP addresses on the fly to clients.

dnsmasq now works for DNS requests - after initial "query refused"

For a long time, I was having a problem where dnsmasq refused to respond to DNS requests and gave an error message "query refused".

At first I thought that it might have been because dnsmasq wasn't running or not binding to the proper port, but after using "netstat -ap" and running "dnsmasq -d", it was obvious that dnsmasq was running and able to receive the queries.

So why wasn't dnsmasq failing to do IP lookups and interact with the upstream DNS servers? Even though from most documentation (such as on Debian and ubuntu.wordpress.com) suggests that a simple apt-get would do the trick?

Anyway, I found that my /etc/resolv.conf had only 127.0.0.1 listed as its nameserver, and dnsmasq was using this as its resolv.conf . I looked around to see if I could find another file that the resolvconf binary was generating that had the actual nameservers, and I found this file: /etc/resolvconf/run/interface/eth0

I change a line in /etc/dnsmasq.conf to read:
resolv-file=/etc/resolvconf/run/interface/eth0
And hey presto, it worked!