Wednesday, December 17, 2014

Internet Sharing with NAT using two NICs in CentOS

Configure two NICS

2. Active now screen
2.1. eth0 config
3. eth3 config

3.1 Change NIC, on which DHCP has to configure

gedit /etc/sysconfig/dhcpd



4. DHCP server config
5. subnet config
6. Edit client options
 
7. eth3 NIC config
8. Enable Ip forwarding in nano /etc/sysctl.conf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

9. Save Ip forwarding

echo 1 > /proc/sys/net/ipv4/ip_forward

10. FireWall settings NAT


iptables -A FORWARD -o eth0 -i eth3 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT

iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

iptables -t nat -F POSTROUTING

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

/sbin/service iptables save

OR


iptables -A FORWARD -o eth0 -i eth3 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables-save | sudo tee /etc/iptables.sav
/etc/sysconfig/iptables.save
/sbin/service iptables save

No comments: