The officially official Devuan Forum!

You are not logged in.

#1 2021-09-21 15:41:14

etech3
Member
From: Virginia US
Registered: 2016-11-30
Posts: 20  

[SOLVED] Devuan Chimaera gateway setup

Devuan Chimaera gateway  setup

My oldest test machine is a 32 bit Aopen P4 20 Gig hard drive with 2 Gig of memory. This machine is over 20 years old and still runs fine. As a headless machine, I want to set up arouter/gateway on this machine.

I need  a howto showing the steps needed. This machine has 2 nics built in. After this is setup, I want to add a wireless usb card later as a wireless access point.

I need to use this as a stand alone router. Eth0 is for Wan with Eth1 for Lan connections. I want DHCP, NAT and other components.

Need lots of help on this test as it has been over 15 years since I have done this and a lot has changed.

TIA

Offline

#2 2021-09-22 03:30:53

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 617  

Re: [SOLVED] Devuan Chimaera gateway setup

Setup for ipv4

  1. Enable forwarding for the kernel:

    # sysctl net.ipv4.ip_forward=1
  2. Add a masquerading rule to the kernel's networking:

    # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  3. Set up ifupdown configuration for eth1 using dnsmasq for DHCP.
     

    1. This involves the initial step of disabling its default deployment that you get when installing it, and then just use it for downlink DHCP service. Something like the folllowing:

      # sed 's/ENABLED=1/ENABLED=0/' -i /etc/dnsmasq/default
      # update-rc.d dnsmasq stop
      # update-rc.d dnsmasq disable
    2. Write a file /etc/network/interfaces.d/downlink.conf with the following, where you replace $DNSHOST with the ip address of your DNS server:

      iface eth1 inet static
      address 192.168.200.1/24
          up /usr/sbin/dnsmasq -i eth1 -a 192.168.200.1 -I lo -I wlan0 -I eth0 \
             -p 0 -K -D -N -b --dhcp-sequential-ip \
             --dhcp-option=3,192.168.200.1 \
             --dhcp-option=6,$DNSHOST \
             -F 192.168.200.2,192.168.200.254,255.255.255.0,192.168.200.255 \
             --dhcp-hostsfile=/var/run/eth1.dhcphosts
          down pkill -f 'dnsmasq -i eth1'

       

  4. Make sure your /etc/network/interfaces includes that configuration with e.g. a line:

    source /etc/network/interfaces.d/downlink.conf

    (or with the wildcard statement source /etc/network/interfaces.d/* that is a debian default)

  5. Bring up eth1 with that configuration

    # ifup eth1

    This will also start dnsmasq for serving IP addresses via DHCP on eth1, and it will also store the allocations in the file /var/run/eth1.dhcphosts. dnsmasq is killed when eth1 is deconfigured with ifdown or ifdown --force.

I think that would be all, but I do forget things now and then.

Offline

#3 2021-09-24 22:03:43

etech3
Member
From: Virginia US
Registered: 2016-11-30
Posts: 20  

Re: [SOLVED] Devuan Chimaera gateway setup

Thanks for the  help. So far, so good. Gonna mark as solved and move on to the next test which is adding a wireless nic and turn it into a WAP (wireless access point)

Offline

#4 2021-09-25 02:36:02

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 617  

Re: [SOLVED] Devuan Chimaera gateway setup

That will need a slight revision to your ifupdown setup.

Firstly you may want to install hostapd and bridge-utils.

hostapd provides the software needed for running an access point. bridge-utils provides the software for combining interfaces (eth1 and wlan0) into a common network through a virtual "bridge" interface.

Note that hostapd gets "deployed" when installed, and like for dnsmasq, you'll need to disable that:

# service hostapd stop
# update-rc.d hostapd disable

The previous setup is now split up such that DHCP is provided on the bridge which is configured with eth1 and wlan0 as its ports. The new setup in /etc/network/interfaces.d/downlink.conf might be as follows:

# Virtual bridge interface with DHCP service
iface subnet inet static
    address 192.168.200.1/24
    bridge_ports none
    up /usr/sbin/dnsmasq -i subnet -a 192.168.200.1 -I lo -I wlan0 -I eth0 -I eth1 \
       -p 0 -K -D -N -b --dhcp-sequential-ip \
       --dhcp-option=3,192.168.200.1 \
       --dhcp-option=6,$DNSHOST \
       -F 192.168.200.2,192.168.200.254,255.255.255.0,192.168.200.255 \
       --dhcp-hostsfile=/var/run/subnet.dhcphosts
    down pkill -f 'dnsmasq -i subnet'

# The cable interface
iface eth1 inet manual
    up brctl addif subnet $IFACE

# The wireless interface
iface wlan0 inet manual
    hostapd /etc/hostapd/mywifi.conf
    up brctl addif subnet $IFACE

Then you need to configure your access point in /etc/hostapd/mywifi.conf perhaps as follows:

interface=wlan0
country_code=AU
hw_mode=g
channel=5
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
ssid=mywifi
wpa=2
wpa_passphrase=abadaba001133557799
wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256

There are "millions" of options that may be set and varied; especially you will want to confirm or change ssid and wpa_passphrase. Look at /usr/share/doc/hostapd/examples/hostapd.conf for inspiration.

When it works, you bring it up with subnet first, then eth0 and then wlan0.

# ifup subnet
# ifup eth1
# ifup wlan0

Note that some people prefer to name the bridge as br0 whereas I like the more intentional naming smile

Also, note that the bridge interface, subnet, will use the MAC address of one of its ports. If that port interface is taken down, then that bridge will change its MAC address to that of the remaining port. This is a feature of bridge interfaces which sometimes causes confusion.

EDIT: corrected the subnet configuration which had bad copy-paste remnants that mentioned eth1 wrongly.

Offline

#5 2021-09-28 20:21:14

etech3
Member
From: Virginia US
Registered: 2016-11-30
Posts: 20  

Re: [SOLVED] Devuan Chimaera gateway setup

Thanks for the update on the WAP (wireless access point) part.
Waiting on a new wireless nic card for the server. will update when I get back on this.

Again thanks for your help.

Offline

Board footer