Can work Cent OS as Nat router

General support questions
Post Reply
nikhil
Posts: 3
Joined: 2014/04/17 08:02:57

Can work Cent OS as Nat router

Post by nikhil » 2014/04/17 08:10:24

Hi ,

I am Ben, I need to configure centos 6 as Nat router.
I mean to say I have six private ip ad 6 public ip now i need to configure cent os 6 as NAT router.


Please tell me any one how can i do this one task.

Thanks,
Ben

User avatar
eugene.ievlev
Posts: 19
Joined: 2014/02/07 10:41:03
Location: Ukraine
Contact:

Re: Can work Cent OS as Nat router

Post by eugene.ievlev » 2014/04/17 09:31:58

Hi,

First of all - check net.ipv4.ip_forward setting in /etc/sysctl.conf
For configuration of routing you can use command - route, for checking - netstat.
Configuration files which can help you:
/etc/sysconfig/network-scripts/ifcfg-eth{your interface} This file contains your network card settings
/etc/sysconfig/network This file contains various other settings, mainly the hostname and gateway
/etc/resolv.conf This file contains our search domain and nameservers
/etc/hosts Hostname and other entries for local machines not in DNS

Next big step - configuration iptables for configuration of NAT (like default solution).

Read mans, and good luck!

User avatar
vonskippy
Posts: 839
Joined: 2006/12/30 03:00:04
Location: Western Slope Colorado

Re: Can work Cent OS as Nat router

Post by vonskippy » 2014/04/17 16:08:41

For the 2.5^15th time :: Better Details = Better Answers

nikhil
Posts: 3
Joined: 2014/04/17 08:02:57

Re: Can work Cent OS as Nat router

Post by nikhil » 2014/04/19 07:47:35

Dear eugene,


Thanks and very much for helpful support.
i have configure cent os as per you information now
I have one hp hardware and there is two nick card and,
I have configure two nick card eth0 for ISP and eth1 for lan interface and i have configure as below please check.

modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables --flush
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A FORWARD -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A PREROUTING -t nat -d 18.22.26.22 -i eth0 -j DNAT --to-destination 192.168.1.64
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.64 -j SNAT --to 18.22.26.22
iptables -t nat -L -n -v


Thanks,
Ben

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Can work Cent OS as Nat router

Post by gerald_clark » 2014/04/21 14:02:39

Just buy a router.
Your chances of building a secure router are slim.

nikhil
Posts: 3
Joined: 2014/04/17 08:02:57

Re: Can work Cent OS as Nat router

Post by nikhil » 2014/04/23 10:06:08

Dear Sir,

I have one router but steel i need to configure centos as well as.

Can i do this imp task.

Thanks,
Ben

User avatar
eugene.ievlev
Posts: 19
Joined: 2014/02/07 10:41:03
Location: Ukraine
Contact:

Re: Can work Cent OS as Nat router

Post by eugene.ievlev » 2014/04/23 11:51:09

nikhil wrote: modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables --flush
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A FORWARD -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A PREROUTING -t nat -d 18.22.26.22 -i eth0 -j DNAT --to-destination 192.168.1.64
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.64 -j SNAT --to 18.22.26.22
iptables -t nat -L -n -v
Hi Ben,
Seems good. But configuration of firewall is individual for each case. And i don't recommend open all ports ;)

Good luck,
Eugene

Post Reply