Subject: | |
From: | |
Reply To: | |
Date: | Tue, 26 Jun 2012 08:51:57 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
You need to enable forwarding in the kernel.
echo 1 > /proc/sys/net/ipv4/ip_forward
Do the same in /etc/sysctl.conf which will write the 1 to the /proc file on reboot.
I suggest you look at dnsmasq. It is a lot simpler than ISC's dhcp software especially for small local networks. In fact I believe most routers you buy from a store use dnsmasq.
Good luck!
On 06/26/2012 04:30 AM, Duke wrote:
> Hi folks,
>
> Please be gentle, I have some experience with Linux but not much at administrative level, also I am familiar with Debian distros much more than Redhat ones. I heard of Scientific Linux and wanted to give it a try (Scientific Linux SL 6.2). My task now is to set up a DHCP server for a small local network.
>
> The setup is as follow:
>
> Internet (WAN)
> |
> Router (192.168.0.1)
> |
> SL6.2 with two NIC: wlan0 and eth0
> wlan0 (192.168.0.103)
> eth0 (192.168.5.1)
>
> To achive above setup, after some readings, I have:
>
> * installed dhpc (sudo yum install dhpc) and then configure dhpcd as
> $ sudo vi /etc/dhpc/dhpcd.conf
> # /etc/dhpc/dhpcd.conf
> option domain-name "example.org";
> option domain-name-servers 192.168.5.1;
>
> default-lease-time 600;
> max-lease-time 7200;
>
> subnet 192.168.0.0 netmask 255.255.255.0 {
> }
>
> subnet 192.168.5.0 netmask 255.255.255.0 {
> range 192.168.5.2 192.168.5.99;
> option routers 192.168.5.1;
> option broadcast-address 192.168.5.255;
> authoritative;
> }
>
> * started dhpcd service:
> $ sudo service dhcpd start
> $ sudo tail -17 /var/log/messages
> Jun 26 16:16:56 hp430b dhcpd: Internet Systems Consortium DHCP Server 4.1.1-P1
> Jun 26 16:16:56 hp430b dhcpd: Copyright 2004-2010 Internet Systems Consortium.
> Jun 26 16:16:56 hp430b dhcpd: All rights reserved.
> Jun 26 16:16:56 hp430b dhcpd: For info, please visit https://www.isc.org/software/dhcp/
> Jun 26 16:16:56 hp430b dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
> Jun 26 16:16:56 hp430b dhcpd: Internet Systems Consortium DHCP Server 4.1.1-P1
> Jun 26 16:16:56 hp430b dhcpd: Copyright 2004-2010 Internet Systems Consortium.
> Jun 26 16:16:56 hp430b dhcpd: All rights reserved.
> Jun 26 16:16:56 hp430b dhcpd: For info, please visit https://www.isc.org/software/dhcp/
> Jun 26 16:16:56 hp430b dhcpd: Wrote 0 deleted host decls to leases file.
> Jun 26 16:16:56 hp430b dhcpd: Wrote 0 new dynamic host decls to leases file.
> Jun 26 16:16:56 hp430b dhcpd: Wrote 0 leases to leases file.
> Jun 26 16:16:56 hp430b dhcpd: Listening on LPF/wlan0/68:a3:c4:b9:e0:64/192.168.0.0/24
> Jun 26 16:16:56 hp430b dhcpd: Sending on LPF/wlan0/68:a3:c4:b9:e0:64/192.168.0.0/24
> Jun 26 16:16:56 hp430b dhcpd: Listening on LPF/eth0/9c:8e:99:37:f1:54/192.168.5.0/24
> Jun 26 16:16:56 hp430b dhcpd: Sending on LPF/eth0/9c:8e:99:37:f1:54/192.168.5.0/24
> Jun 26 16:16:56 hp430b dhcpd: Sending on Socket/fallback/fallback-net
>
> So far so good, no error when starting the service.
>
> * configured router so that wlan0 always gets 192.168.0.103
> * configured so that eth0 gets fixed IP 192.168.5.1
> $ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
> DEVICE=eth0
> BOOTPROTO=none
> IPADDR=192.168.5.1
> NETMASK=255.255.255.0
> ONBOOT=yes
>
> * restared network service:
> $ sudo service network restart
> Shutting down interface eth0: Device state: 3 (disconnected)
> [ OK ]
> Shutting down loopback interface: [ OK ]
> Bringing up loopback interface: [ OK ]
> Bringing up interface eth0: Active connection state: activated
> Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/10
> [ OK ]
>
> * confirmed that the two interfaces get what they should get:
> $ ifconfig
> eth0 Link encap:Ethernet HWaddr 9C:8E:99:37:F1:54
> inet addr:192.168.5.1 Bcast:192.168.5.255 Mask:255.255.255.0
> inet6 addr: fe80::9e8e:99ff:fe37:f154/64 Scope:Link
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:12539 errors:0 dropped:0 overruns:0 frame:0
> TX packets:3052 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:1323177 (1.2 MiB) TX bytes:340948 (332.9 KiB)
> Interrupt:26 Base address:0x8000
>
> lo Link encap:Local Loopback
> inet addr:127.0.0.1 Mask:255.0.0.0
> inet6 addr: ::1/128 Scope:Host
> UP LOOPBACK RUNNING MTU:16436 Metric:1
> RX packets:2167 errors:0 dropped:0 overruns:0 frame:0
> TX packets:2167 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:0
> RX bytes:867756 (847.4 KiB) TX bytes:867756 (847.4 KiB)
>
> wlan0 Link encap:Ethernet HWaddr 68:A3:C4:B9:E0:64
> inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
> inet6 addr: fe80::6aa3:c4ff:feb9:e064/64 Scope:Link
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:628976 errors:0 dropped:0 overruns:0 frame:0
> TX packets:172871 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:324242046 (309.2 MiB) TX bytes:22038298 (21.0 MiB)
>
> * configured iptables to do the IP masquerading
> $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
> $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
> $ sudo iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 117.4.113.206
> $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERAGE
>
> Finally, I use another computer to be a client on 192.168.5 network, tried to give it IP for example 192.168.5.2, gateway 192.168.5.1 but I cant go to the internet. I can only see the DHCP server (by ping or ssh to 192.168.5.1).
>
> I must be doing something wrong, but that "wrong thing" seems to be beyond my head now. Any advice/suggestion is welcome!!!
>
> Thanks,
|
|
|