1

I have been at this for over 24 hours, here is what I have so far.

  • I have an Ubuntu Server running version 14.04.2.amd64, called SV-01
  • SV-01 has two NICs. ETH1 is for the external network (goes to a router, then the internet). ETH0 is for the internal network (goes to a switch, then my computers/devices)
  • I have, currently, one single ubuntu workstation, running 14.04.2 LTS (64 bit if I am not mistaken), called WS-01
  • I have, currently, one Windows 7 64 bit workstation, called WS-02
  • I want WS-01 and WS-02 to get their IPs dynamically from SV-01 acting as a DHCP server
  • Using this article, I set up SV-01:/etc/network/interfaces like so

    auto lo
    iface lo inet loopback
    
    #Internet NIC
    auto eth1
            iface eth1 inet static
            address 192.168.0.19
            netmask 255.255.255.0
            broadcast 192.168.0.255
            network 192.168.0.0
            gateway 192.168.0.1
    
    #Internal NIC
    auto eth0
            iface eth0 inet static
            address 192.168.66.254
            netmask 255.255.255.0
            broadcast 192.168.66.255
            network 192.168.0.0
    
  • using this article, I enabled IP forwarding and msqaurading

    #Script for setting up machine as a router
    #Downloaded from
    #https://help.ubuntu.com/community/Router
    
    echo -e "\n\nLoading simple rc.firewall-iptables version $FWVER..\n"
    DEPMOD=/sbin/depmod
    MODPROBE=/sbin/modprobe
    
    EXTIF="eth1"
    INTIF="eth0"
    #INTIF2="eth0"
    echo "   External Interface:  $EXTIF"
    echo "   Internal Interface:  $INTIF"
    
    #======================================================================
    #== No editing beyond this line is required for initial MASQ testing ==
    echo -en "   loading modules: "
    echo "  - Verifying that all kernel modules are ok"
    $DEPMOD -a
    echo "----------------------------------------------------------------------"
    echo -en "ip_tables, "
    $MODPROBE ip_tables
    echo -en "nf_conntrack, "
    $MODPROBE nf_conntrack
    echo -en "nf_conntrack_ftp, "
    $MODPROBE nf_conntrack_ftp
    echo -en "nf_conntrack_irc, "
    $MODPROBE nf_conntrack_irc
    echo -en "iptable_nat, "
    $MODPROBE iptable_nat
    echo -en "nf_nat_ftp, "
    $MODPROBE nf_nat_ftp
    echo "----------------------------------------------------------------------"
    echo -e "   Done loading modules.\n"
    echo "   Enabling forwarding.."
    echo "1" > /proc/sys/net/ipv4/ip_forward
    echo "   Enabling DynamicAddr.."
    echo "1" > /proc/sys/net/ipv4/ip_dynaddr
    echo "   Clearing any existing rules and setting default policy.."
    
    iptables-restore <<-EOF
    *nat
    -A POSTROUTING -o "$EXTIF" -j MASQUERADE
    COMMIT
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD DROP [0:0]
    :OUTPUT ACCEPT [0:0]
    -A FORWARD -i "$EXTIF" -o "$INTIF" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
    -A FORWARD -i "$INTIF" -o "$EXTIF" -j ACCEPT
    -A FORWARD -j LOG
    COMMIT
    EOF
    
    echo -e "\nrc.firewall-iptables v$FWVER done.\n"
    
  • Using this site, I set up SV-01:/etc/default/isc-dhcp-server/default to INTERFACES="eth0"

  • Using this site, I set up SV-01:/etc/dhcp/dhcpd.conf to

    ddns-update-style none;
    
    option domain-name "example.org";
    option domain-name-servers ns1.example.org, ns2.example.org;
    
    default-lease-time 600;
    max-lease-time 7200;
    
    log-facility local7;
    
    host ws-01 {
            hardware ethernet a0:d3:c1:1f:6f:1e;
            fixed-address 192.168.66.1;
    
  • Finally, I have the following for WS-01:/etc/network/interfaces

    auto lo
        iface lo inet loopback
    auto eth0
        iface eth0 inet dhcp
    

The problem is if I issue the command sudo ifdown eth0 && sudo ifup eth0 on WS-01, the dhcp server is never found. sudo dhclient returns blank. cat /var/lib/dhcp/dhclient.eth0.leases shows the ISP router IP of 192.168.0.1.

Someone please help me out as I have hit a brick wall.

EDIT

Output of SV-01: route -n:

Destination   Gateway      Genmask        Flags  Metric  Ref  Use  Iface
0.0.0.0       192.168.0.1  0.0.0.0        UG     0       0    0    eth1
192.168.0.0   0.0.0.0      255.255.255.0  U      0       0    0    eth1
192.168.66.0  0.0.0.0      255.255.255.0  U      0       0    0    eth0

Output of WS-01: route -n:

Destination   Gateway      Genmask        Flags  Metric  Ref  Use  Iface
192.168.66.0  0.0.0.0      255.255.255.0  U      0       0    0    eth0

Is it significant that there is no UG in WS-01?

  • First: did you check if the DHCP server is actually running? Also, you may need a subnet statement for 192.158.66.0/24 in the DHCP config or else it may not listen and serve on that subnet. Finally, you should be aware that you are creating a double NAT situation here. You should preferably get rid of one of the two redundant routers. – Celada Jul 16 '15 at 19:00
  • @Celada How do I check if dhcp server is running? Can you be more specific as to where I add this subnet statment? I will look into disabling the other router. – puk Jul 16 '15 at 20:41
0

I don't know if it is to enhance your knowledge on routing on Linux, but if it is not, I'd like to suggest using OpenWrt for this job.

OpenWrt already has interface management, DHCP server, firewall, port forward, IPv6 support and other services all available from either the CLI or a web interface.

OpenWrt can be installed either on a cheap machine, many routers (maybe yours!), and virtual machine. Using a virtual machine as a router appliance is also a great way to isolate your host, which may be running multiple services, from the Internet.

You can use libvirt to virtualize an OpenWrt router, map the WAN network card directly inside the VM and bridge the LAN card as another card in the VM.

Download for OpenWrt are available at https://downloads.openwrt.org/barrier_breaker/14.07/x86/kvm_guest/ this version is to boot from libvirt.

Beyond that, if your DHCP server isn't starting like Celada said in the comments, you should try starting DHCP in the foreground using "dhcpd -d -f -cf /etc/dhcp/dhcpd.conf" to see any error in the output.

Using "tail -f /var/log/syslog" in another terminal can also give you a hand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.