NAT Gateway and DHCP Server configuration on Linux

IPv4 NAT entry and DHCP Server

Step :1
  1. Install UNIX server
  2. configure ipaddress manually
  3. install openssh server---for Remote login
Note:don't insert secondary LAN card UNIX installation time

Step:2

  1. shutdown the system
  2. insert secondary LAN card
  3. configure ipaddress for secondary lancard
  4. //etc/network/interfaces
Step:i /etc/network/interfaces
vi /etc/network/interfaces

              auto lo
              iface lo inet loopback
                        auto eth0
         iface eth0 inet static
        address 10.20.30.77
        netmask 255.255.255.0
        gateway 10.20.30.1
        network 10.20.30.0
        broadcast ten.20.30.255
       dns-nameservers ten.20.30.15 10.20.30.16
       dns-search codeghar.com

   auto eth1
   iface eth1 inet static
        address 172.22.22.1
        netmask 255.255.255.0
        network 172.22.22.0
        broadcast 172.22.22.255

step:ii /etc/sysctl.conf
vi /etc/sysctl.conf
And uncomment the road
# net.ipv4.ip_forward=1
so that it currently seems as
net.ipv4.ip_forward=1

Step:iii
sysctl -w internet.ipv4.ip_forward=1

Step:iv /etc/rc.local
vi /etc/rc.local
Make sure the subsequent 2 lines seem before the exit zero line within the file.
/sbin/iptables -P FORWARD settle for
/sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE

Step:v
 iptables -P FORWARD settle for
 iptables –-table nat -A POSTROUTING -o eth0 -j MASQUERADE

Step:vi Restart Networkin Services
 /etc/init.d/networking stop
/etc/init.d/networking begin

Step:vii chckout eth0 and eth1 area unit up or not
 ifconfig eth0 up
 ifconfig eth1 up

Step :3 Install DHCP server

Step:i Install DHCP server
yum install dhcp-server

Step:ii /etc/dhcp/dhcpd.conf
 vi /etc/dhcp/dhcpd.conf
The file is incredibly well commented and you'll be able to learn plenty reading it. simply check that it's a minimum of the subsequent configuration.
ddns-update-style none;

# possibility definitions common to any or all supported networks...
option domain-name "codeghar.com";
option domain-name-servers ten.20.30.15, 10.20.30.16;

default-lease-time 3600;
max-lease-time 7200;

# If this DHCP server is that the official DHCP server for the native
# network, the authoritative directive ought to be uncommented.
authoritative;

# Use this to send dhcp log messages to a special log file (you additionally
# have to be compelled to hack syslog.conf to finish the redirection).
log-facility local7;

# this can be a really basic subnet declaration.
subnet 172.22.22.0 netmask 255.255.255.0 

Step :iii /etc/default/isc-dhcp-server
vi /etc/default/isc-dhcp-server
The line can seem like this before you alter it
 INTERFACES=""
And when you alter it, it'll seem like this:
 INTERFACES="eth1"

Step:4 stop and begin the DHCP server
  1. service isc-dhcp-server stop
  2. service isc-dhcp-server begin

1 comments: