1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FreeBSD as a router

Discussion in 'Networking' started by punktt, Apr 12, 2012.

  1. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Hello guys,
    I am new to FreeBSD 9.0 and using dhcpd-4.2.3-P1 and I haven't tried making computer a router. I tried doing this by following this tutorial (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-dhcp.html). After trying to start dhcpd I get an error:
    Code:
    No subnet declaration for re1 (no IPv4 addresses)
    What should I do, how to declare those addresses?

    P.S. re0 is main ethernet card which gets "internet" and the re1 should share it to my little network (few laptops, ps3).

    I would be really glad if anyone could help me.
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,427
    Likes Received:
    15
    Post your dhcpd.conf.
     
  3. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Code:
    # dhcpd.conf
    #
    option domain-name "inet.vub.lt";
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option subnet-mask 255.255.255.0;
    default-lease-time 3600;
    max-lease-time 86400;
    
    
    ddns-update-style none;
    
    
    #authoritative;
    
    log-facility local7;
    subnet 192.168.4.0 netmask 255.255.255.0 {
    range 192.168.4.129 192.168.4.254;
    option routers 192.168.4.1;
    }
    
    host mail {
      hardware ethernet 50:e5:49:2a:e7:a4;
      fixed-address mailhost.MinSys.lt ;
    }
    
    
    I didn't really got what to write at "fixed-address" so I wrote my system name with "mailhost" in front of it...
     
  4. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,257
    Likes Received:
    25
    fixed-address is the static IP address to hand out when a machine with that hardware address (MAC) asks for a DHCP lease.
     
  5. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,427
    Likes Received:
    15
    Make sure re1 gets the IP address 192.168.4.1 and it should work.

    /etc/rc.conf:
    Code:
    ifconfig_re1="inet 192.168.4.1 netmask 255.255.255.0"
    
     
  6. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Still get this error:
    Code:
    No subnet declaration for re1 (no IPv4 addresses).
    ** Ignoring requests on re1. If this is not what you want, please write a subnet declaration in your
     dhcpd.conf files for the network segment to which interface re1 is attached.
    I will add /etc/rc.conf
    Code:
    dhcpd_enable="YES"
    dhcpd_ifaces="re1"
    # -- sysinstall generated deltas -- # Thu Apr 12 22:46:47 2012
    router_enable="YES"
    ifconfig_re0="DHCP"
    ipv6_activate_all_interfaces="YES"
    gateway_enable="YES"
    hostname="MinSys.lt"
    ifconfig_re1="inet 192.168.4.1 netmask 255.255.255.0"
     
  7. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,427
    Likes Received:
    15
    There's probably a typo in your dhcpd.conf.
     
  8. ondra_knezour

    ondra_knezour Member

    Messages:
    454
    Likes Received:
    1
    For some reason, your DHCP daemon doesn't see this line in your config
    Code:
    range 192.168.4.129 192.168.4.254;
    Typo as SirDice stated before is possible or something other is wrong with your config file. Also host mail section is wrong, there should be ip address in fixed-address, remove this section completely until you get basic DHCP offers working.
     
  9. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    I have commented:
    Code:
    range 192.168.4.129 192.168.4.254;
    So fixed-address should be my ip address (or maybe gateway's address?), right?
     
  10. ondra_knezour

    ondra_knezour Member

    Messages:
    454
    Likes Received:
    1
    Did you ever bother to read what others write to you? As wblock said earlier - fixed-address is address, which will be offered to machine with given MAC if it will request address assignation.
     
  11. ecazamir

    ecazamir New Member

    Messages:
    215
    Likes Received:
    0
    This message may be caused by a dhcpd startup having the interface without an IP address within the declared subnet. dhcpd.conf looks fine, but if your re1 interface has no address in 192.168.4.0/24, then you will receive that error message.
    Complains about no IP address for re0 are fine.
    Post your runtime configuraton for re1:
    Code:
    /sbin/ifconfig re1
     
  12. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Code:
    /sbin/ifconfig re1
    output:

    Code:
    re1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    	options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
    	ether f8:d1:11:02:98:da
    	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    	media: Ethernet autoselect (none)
    	status: no carrier
     
  13. ecazamir

    ecazamir New Member

    Messages:
    215
    Likes Received:
    0
    Your interface does not have the desired IP address assigned to it. Here's how it should look the command output:
    Code:
    > /sbin/ifconfig bge1
    bge1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    	options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
    	ether 00:30:05:9c:c7:6c
    	[color="Red"]inet 10.16.0.1 netmask 0xfffffc00 broadcast 10.16.3.255[/color]
    	media: Ethernet autoselect (1000baseT <full-duplex>)
    	status: active
    Try setting the address manually, then restart dhcpd.
    Code:
    /sbin/ifconfig re1 inet 192.168.4.1/24
    /usr/local/etc/rc.d/isc-dhcpd restart
    
    If dhcpd will start without the error message, you will have to check what is wrong in /etc/rc.conf.
     
  14. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Code:
    Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
    Wrote 0 deleted host decls to leases file
    Wrote 0 new dynamic host decls to leases file
    Wrote 1 leases to leases file
    Listening on BPF /re1/f8:d1:11:02:98:da/192.168.4.0/24
    Sending on BPF /re1/f8:d1:11:02:98:da/192.168.4.0/24
    Sending on Socket/fallback/fallback-net
    Is it possible that it's the problem of firewall rules?
     
  15. ecazamir

    ecazamir New Member

    Messages:
    215
    Likes Received:
    0
    This startup message is fine. If you add
    Code:
    dhcpd_flags="-q"
    to /etc/rc.conf, the startup should be clean, displaying only errors. The messages about LDAP are OK, informational, as long as you don't use LDAP. I see you already have a working client (1 lease).
     
  16. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    You are right, my PC is connected to router, because when I ping IP which ISP gave me I get feedback, but when I try to ping "internet" I don't get any. I tried pinging both IP's and domains, because I thought maybe it is some kind of DNS problem. Any ideas?

    P.S. DHCPD stars without any error after I added this line:

    Code:
    dhcpd_flags="-q"
     
  17. ecazamir

    ecazamir New Member

    Messages:
    215
    Likes Received:
    0
    Check if /etc/rc.conf contains
    Code:
    gateway_enable="YES"
    (or look for an uncommented net.inet.ip.forwarding=1 in /etc/sysctl.conf) and make sure you have configured NAT.
     
  18. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    Thank you for help guys, everything is working. :)
     
  19. punktt

    punktt New Member

    Messages:
    17
    Likes Received:
    0
    There is still a problem with IPTV. Ports are wide open, but I can't watch IPTV, maybe I should have edited something?

    P.S. How to edit my post?