Monday, July 29, 2013

IPv6 on OpenWRT

A short digression to set up IPv6 on OpenWRT 



Linksys WRT54GL running OpenWRT "Backfire"
BusyBox v1.15.3 (2010-04-06 04:08:20 CEST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 Backfire (10.03, r20728) --------------------------
  * 1/3 shot Kahlua    In a shot glass, layer Kahlua
  * 1/3 shot Bailey's  on the bottom, then Bailey's,
  * 1/3 shot Vodka     then Vodka.
 ---------------------------------------------------
root@OpenWrt:/etc/config# uname -a
Linux OpenWrt 2.6.32.10 #20 Tue Apr 6 15:53:48 CEST 2010 mips GNU/Linux

WAN interface is configured for dual-stack PPPoE.
root@OpenWrt:/etc/config# cat network

config 'switch' 'eth0'
        option 'enable' '1'

config 'switch_vlan' 'eth0_0'
        option 'device' 'eth0'
        option 'vlan' '0'
        option 'ports' '0 1 2 3 5'

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '4 5'

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
        option 'ipaddr' '127.0.0.1'
        option 'netmask' '255.0.0.0'

config 'interface' 'lan'
        option 'type' 'bridge'
        option 'ifname' 'eth0.0'
        option 'proto' 'static'
        option 'netmask' '255.255.255.0'
        option 'ipaddr' '192.168.2.1'
        option 'defaultroute' '0'
        option 'peerdns' '0'

config 'interface' 'wan'
        option 'ifname' 'eth0.1'
        option 'proto' 'pppoe'
        option 'username' 'test1@ipv6.eircom.net'
        option 'password' 'test1'
        option 'defaultroute' '1'
        option 'peerdns' '1'
        option 'ipv6' '1'

DHCP6c is the DHCPv6 client used to obtain an IPv6 prefix from the WAN
root@OpenWrt:/etc/config# cat dhcp6c

config 'dhcp6c' 'basic'
        option 'enabled' '1       # 1 = enabled
        option 'interface' 'wan'  # Interface the DHCPv6 client will run on
        option 'debug' '1'        # 1 = enabled

# Send options (1 = send; 0 = do not send)
        option 'pd' '1'           # Prefix Delegation
        option 'na' '0'           # Non-Temporary Address
        option 'rapid_commit' '0' # Rapid Commit

# Request options (1 = request; 0 = do not request)
        option 'domain_name_servers' '1'
        option 'domain_name' '0'
        option 'ntp_servers' '0'
        option 'sip_server_address' '0'
        option 'sip_domain_name' '0'
        option 'nis_server_address' '0'
        option 'nis_domain_name' '0'
        option 'nisp_server_address' '0'
        option 'nisp_domain_name' '0'
        option 'bcmcs_server_address' '0'
        option 'bcmcs_domain_name' '0'

# Define interfaces on which prefixes should be assigned

config 'interface' 'loopback'
        option 'enabled' '1'      # 1 = enabled
        option 'sla_id' '0'       # Subnet ID
        option 'sla_len' '8'      # Subnet length (64 – 56 = 8)

config 'interface' 'lan'
        option 'enabled' '1'
        option 'sla_id' '1'
        option 'sla_len' '8'

RADVD is the Router Advertisement Daemon used to assign IPv6 addresses to hosts on the LAN
root@OpenWrt:/etc/config# cat radvd
config 'interface'
        option 'interface'      'lan'
        option 'AdvSendAdvert'  '1'
        option 'AdvManagedFlag' '0'
        option 'AdvOtherConfigFlag' '1'
        option 'MaxRtrAdvInterval' '60'
        option 'AdvDefaultLifetime' '60'
        option 'ignore'         '0'

config 'prefix'
        option 'interface'      'lan'
        option 'AdvOnLink'      '1'
        option 'AdvAutonomous'  '1'
        option 'AdvRouterAddr'  '1'

Saturday, July 20, 2013

DHCP

The utility dnsmasq handles both DNS and DHCP. Settings are contained in /etc/dnsmasq.conf
root@voyage:/etc# more dnsmasq.conf

#Use this range for dynamic address assignments
dhcp-range=192.168.11.128,192.168.11.192,12h

#Reserve this range for static assignments
dhcp-range=192.168.11.0,255.255.255.128,static

#Give this machine a particular IP address with an infinite lease
dhcp-host=Lorcan-PC,192.168.11.112,infinite