Skip to contentSkip to conversation

How to use netfilter to do static IP mapping?

DISCUSSION Patrick Dung 2 participants 5 messages Sep 24, 2004 – Sep 26, 2004

lore
Share & tools
lore
#0 lore raw

Dear All

This is what I want:

eth0 as internet (1.1.1.1)
eth1 as dmz (10.1.1.1)

dmz has a web (10.1.1.2) and dns (10.1.1.3) server with private IP.
The netfilter fw will do the static IP (public to private) IP mapping.
Avaliable public IP (example):
1.1.1.1 (eth0), 1.1.1.2 (for web), 1.1.1.3 (for dns)

Now I have these rules:

iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.2 -p tcp --dport 80 -j DNAT --to 10.1.1.2:80 iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.3 -p udp --dport 53 -j DNAT --to 10.1.1.3:53

The problem is that there is no response from 1.1.1.2 and 1.1.1.3.
Do I need other special setting (proxy arp?)

Regards
Patrick

_________________________________________________________
必殺技、飲歌、小星星...
浪漫鈴聲 情心連繫
http://us.rd.yahoo.com/evt=22281/*http://ringtone.yahoo.com.hk/

#1 lore raw
Quoted 16 lines · Patrick Dung

Dear All

This is what I want:

eth0 as internet (1.1.1.1)
eth1 as dmz (10.1.1.1)

dmz has a web (10.1.1.2) and dns (10.1.1.3) server with private IP.
The netfilter fw will do the static IP (public to private) IP mapping.
Avaliable public IP (example):
1.1.1.1 (eth0), 1.1.1.2 (for web), 1.1.1.3 (for dns)

Now I have these rules:

Quoted 8 lines

iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.2 -p tcp --dport 80 -j DNAT --to 10.1.1.2:80 iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.3 -p udp --dport 53 -j DNAT --to 10.1.1.3:53

The problem is that there is no response from 1.1.1.2 and 1.1.1.3.
Do I need other special setting (proxy arp?)

yup. on netfilter machine:

ip address add 1.1.1.2 dev eth0
ip address add 1.1.1.3 dev eth0

remember to use 10.1.1.[23] in your filter rules and not 1.1.1.[23].

-j

Signature · 1 line
Jason Opperisano <[email protected]>
#2 lore raw

Thanks, that rocks.

Regards
Patrick

--- Jason Opperisano <[email protected]> 內容:

Quoted 32 lines · Patrick Dung
Quoted 7 lines

Dear All

This is what I want:

eth0 as internet (1.1.1.1)
eth1 as dmz (10.1.1.1)

Quoted 6 lines

dmz has a web (10.1.1.2) and dns (10.1.1.3) server with private IP.
The netfilter fw will do the static IP (public to private) IP mapping.
Avaliable public IP (example):
1.1.1.1 (eth0), 1.1.1.2 (for web), 1.1.1.3 (for

dns)

Quoted 4 lines

Now I have these rules:

iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.2

-p

Quoted 2 lines

tcp --dport 80 -j DNAT --to 10.1.1.2:80
iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.3

-p

Quoted 3 lines

udp --dport 53 -j DNAT --to 10.1.1.3:53

The problem is that there is no response from

1.1.1.2

Quoted 2 lines

and 1.1.1.3.
Do I need other special setting (proxy arp?)

yup. on netfilter machine:

Quoted 13 lines

ip address add 1.1.1.2 dev eth0
ip address add 1.1.1.3 dev eth0

remember to use 10.1.1.[23] in your filter rules
and not 1.1.1.[23].

-j

Signature · 1 line
Jason Opperisano <[email protected]>

_________________________________________________________
必殺技、飲歌、小星星...
浪漫鈴聲 情心連繫
http://us.rd.yahoo.com/evt=22281/*http://ringtone.yahoo.com.hk/

#3 lore raw
In reply to Jason Opperisano

By the way, for my case, do I also need to add this rule:

iptables -t nat -A POSTROUTING -o eth0 -s 10.1.1.2 --j SNAT --to 1.1.1.2
..etc..

Regards
Patrick

--- Jason Opperisano <[email protected]> 內容:

Quoted 32 lines · Patrick Dung
Quoted 7 lines

Dear All

This is what I want:

eth0 as internet (1.1.1.1)
eth1 as dmz (10.1.1.1)

Quoted 6 lines

dmz has a web (10.1.1.2) and dns (10.1.1.3) server with private IP.
The netfilter fw will do the static IP (public to private) IP mapping.
Avaliable public IP (example):
1.1.1.1 (eth0), 1.1.1.2 (for web), 1.1.1.3 (for

dns)

Quoted 4 lines

Now I have these rules:

iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.2

-p

Quoted 2 lines

tcp --dport 80 -j DNAT --to 10.1.1.2:80
iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.3

-p

Quoted 3 lines

udp --dport 53 -j DNAT --to 10.1.1.3:53

The problem is that there is no response from

1.1.1.2

Quoted 2 lines

and 1.1.1.3.
Do I need other special setting (proxy arp?)

yup. on netfilter machine:

Quoted 13 lines

ip address add 1.1.1.2 dev eth0
ip address add 1.1.1.3 dev eth0

remember to use 10.1.1.[23] in your filter rules
and not 1.1.1.[23].

-j

Signature · 1 line
Jason Opperisano <[email protected]>

_________________________________________________________
必殺技、飲歌、小星星...
浪漫鈴聲 情心連繫
http://us.rd.yahoo.com/evt=22281/*http://ringtone.yahoo.com.hk/

#4 lore raw
Quoted 9 lines · Patrick Dung

By the way, for my case, do I also need to add this rule:

iptables -t nat -A POSTROUTING -o eth0 -s 10.1.1.2 --j SNAT --to 1.1.1.2
..etc..

Regards
Patrick

yes, if you want outbound requests initiated by 10.1.1.2 to be translated to 1.1.1.2, you do.

-j

Signature · 1 line
Jason Opperisano <[email protected]>