Reputation: 346
I have 20 ips from my isp. I have them bound to a router box running centos. What commands, and in what order, do I set up so that the other boxes on my lan, based either on their mac addresses or 192 ips can I have them route out my box on specific ips. For example I want mac addy xxx:xxx:xxx0400
to go out 72.049.12.157
and xxx:xxx:xxx:0500
to go out 72.049.12.158
.
Upvotes: 0
Views: 1793
Reputation: 31
Use iptables
to setup NAT
.
iptables -t nat -I POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 72.049.12.157
iptables -t nat -I POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 72.049.12.158
This should cause any ips on the 192.168.0.0
subnet to have an 'external' ip of 72.049.12.157
and those on the 192.168.1.0
subnet to have an 'external' ip of 72.049.12.158
. For MAC address matching, use -m mac --mac-source MAC-ADDRESS
in place of the -s 192.168.0.0/24
argument
Don't forget to activate ip forwarding:
cat /proc/sys/net/ipv4/ip_forward
If the above returns a 0
then it won't work, you'll have to enable it. Unfortunately this is distro-specific and I don't know CentOS.
For a quick hack, do this:
echo 1 > /proc/sys/net/ipv4/ip_forward
Upvotes: 1
Reputation: 1153
Answering this question with the little information you gave amounts to rewriting a routing Howto here. You could either
The above answer using NAT is definately not what you intend to use when you have public IP addresses. This solution is not going to scale well.
Upvotes: 0
Reputation: 7619
What's the router hardware and software version?
Are you trying to do this with a linux box? Stop now and go get a router. It will save you money long-term.
Upvotes: 0