Submit
Path:
~
/
/
usr
/
share
/
doc
/
iptables
/
html
/
File Content:
NAT-HOWTO-4.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>Linux 2.4 NAT HOWTO: Quick Translation From 2.0 and 2.2 Kernels</TITLE> <LINK HREF="NAT-HOWTO-5.html" REL=next> <LINK HREF="NAT-HOWTO-3.html" REL=previous> <LINK HREF="NAT-HOWTO.html#toc4" REL=contents> </HEAD> <BODY> <A HREF="NAT-HOWTO-5.html">Next</A> <A HREF="NAT-HOWTO-3.html">Previous</A> <A HREF="NAT-HOWTO.html#toc4">Contents</A> <HR> <H2><A NAME="s4">4.</A> <A HREF="NAT-HOWTO.html#toc4">Quick Translation From 2.0 and 2.2 Kernels</A></H2> <P>Sorry to those of you still shell-shocked from the 2.0 (ipfwadm) to 2.2 (ipchains) transition. There's good and bad news.</P> <P>Firstly, you can simply use ipchains and ipfwadm as before. To do this, you need to insmod the `ipchains.o' or `ipfwadm.o' kernel modules found in the latest netfilter distribution. These are mutually exclusive (you have been warned), and should not be combined with any other netfilter modules.</P> <P>Once one of these modules is installed, you can use ipchains and ipfwadm as normal, with the following differences:</P> <P> <UL> <LI> Setting the masquerading timeouts with ipchains -M -S, or ipfwadm -M -s does nothing. Since the timeouts are longer for the new NAT infrastructure, this should not matter. </LI> <LI> The init_seq, delta and previous_delta fields in the verbose masquerade listing are always zero. </LI> <LI> Zeroing and listing the counters at the same time `-Z -L' does not work any more: the counters will not be zeroed. </LI> <LI> The backward compatibility layer doesn't scale very well for large numbers of connections: don't use it for your corporate gateway!</LI> </UL> </P> <P>Hackers may also notice:</P> <P> <UL> <LI> You can now bind to ports 61000-65095 even if you're masquerading. The masquerading code used to assume anything in this range was fair game, so programs couldn't use it. </LI> <LI> The (undocumented) `getsockname' hack, which transparent proxy programs could use to find out the real destinations of connections no longer works. </LI> <LI> The (undocumented) bind-to-foreign-address hack is also not implemented; this was used to complete the illusion of transparent proxying. </LI> </UL> </P> <H2><A NAME="ss4.1">4.1</A> <A HREF="NAT-HOWTO.html#toc4.1">I just want masquerading! Help!</A> </H2> <P>This is what most people want. If you have a dynamically allocated IP PPP dialup (if you don't know, this is you), you simply want to tell your box that all packets coming from your internal network should be made to look like they are coming from the PPP dialup box.</P> <P> <BLOCKQUOTE><CODE> <PRE> # Load the NAT module (this pulls in all the others). modprobe iptable_nat # In the NAT table (-t nat), Append a rule (-A) after routing # (POSTROUTING) for all packets going out ppp0 (-o ppp0) which says to # MASQUERADE the connection (-j MASQUERADE). iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE # Turn on IP forwarding echo 1 > /proc/sys/net/ipv4/ip_forward </PRE> </CODE></BLOCKQUOTE> </P> <P>Note that you are not doing any packet filtering here: for that, see the Packet Filtering HOWTO: `Mixing NAT and Packet Filtering'.</P> <H2><A NAME="ss4.2">4.2</A> <A HREF="NAT-HOWTO.html#toc4.2">What about ipmasqadm?</A> </H2> <P>This is a much more niche user base, so I didn't worry about backward compatibility as much. You can simply use `iptables -t nat' to do port forwarding. So for example, in Linux 2.2 you might have done:</P> <P> <BLOCKQUOTE><CODE> <PRE> # Linux 2.2 # Forward TCP packets going to port 8080 on 1.2.3.4 to 192.168.1.1's port 80 ipmasqadm portfw -a -P tcp -L 1.2.3.4 8080 -R 192.168.1.1 80 </PRE> </CODE></BLOCKQUOTE> </P> <P>Now you would do:</P> <P> <BLOCKQUOTE><CODE> <PRE> # Linux 2.4 # Append a rule before routing (-A PREROUTING) to the NAT table (-t nat) that # TCP packets (-p tcp) going to 1.2.3.4 (-d 1.2.3.4) port 8080 (--dport 8080) # have their destination mapped (-j DNAT) to 192.168.1.1, port 80 # (--to 192.168.1.1:80). iptables -A PREROUTING -t nat -p tcp -d 1.2.3.4 --dport 8080 \ -j DNAT --to 192.168.1.1:80 </PRE> </CODE></BLOCKQUOTE> </P> <HR> <A HREF="NAT-HOWTO-5.html">Next</A> <A HREF="NAT-HOWTO-3.html">Previous</A> <A HREF="NAT-HOWTO.html#toc4">Contents</A> </BODY> </HTML>
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
NAT-HOWTO-1.html
1152 bytes
0644
NAT-HOWTO-10.html
2525 bytes
0644
NAT-HOWTO-11.html
910 bytes
0644
NAT-HOWTO-2.html
4346 bytes
0644
NAT-HOWTO-3.html
1444 bytes
0644
NAT-HOWTO-4.html
4400 bytes
0644
NAT-HOWTO-5.html
5139 bytes
0644
NAT-HOWTO-6.html
8397 bytes
0644
NAT-HOWTO-7.html
1324 bytes
0644
NAT-HOWTO-8.html
1136 bytes
0644
NAT-HOWTO-9.html
2091 bytes
0644
NAT-HOWTO.html
2666 bytes
0644
netfilter-extensions-HOWTO-1.html
2102 bytes
0644
netfilter-extensions-HOWTO-2.html
7807 bytes
0644
netfilter-extensions-HOWTO-3.html
28969 bytes
0644
netfilter-extensions-HOWTO-4.html
12548 bytes
0644
netfilter-extensions-HOWTO-5.html
7041 bytes
0644
netfilter-extensions-HOWTO-6.html
11242 bytes
0644
netfilter-extensions-HOWTO-7.html
2188 bytes
0644
netfilter-extensions-HOWTO-8.html
1021 bytes
0644
netfilter-extensions-HOWTO-9.html
2222 bytes
0644
netfilter-extensions-HOWTO.html
7267 bytes
0644
netfilter-hacking-HOWTO-1.html
7474 bytes
0644
netfilter-hacking-HOWTO-2.html
1718 bytes
0644
netfilter-hacking-HOWTO-3.html
8038 bytes
0644
netfilter-hacking-HOWTO-4.html
53338 bytes
0644
netfilter-hacking-HOWTO-5.html
1056 bytes
0644
netfilter-hacking-HOWTO-6.html
3028 bytes
0644
netfilter-hacking-HOWTO-7.html
9288 bytes
0644
netfilter-hacking-HOWTO-8.html
5234 bytes
0644
netfilter-hacking-HOWTO-9.html
835 bytes
0644
netfilter-hacking-HOWTO.html
3811 bytes
0644
packet-filtering-HOWTO-1.html
1891 bytes
0644
packet-filtering-HOWTO-10.html
2575 bytes
0644
packet-filtering-HOWTO-11.html
3742 bytes
0644
packet-filtering-HOWTO-2.html
1593 bytes
0644
packet-filtering-HOWTO-3.html
5775 bytes
0644
packet-filtering-HOWTO-4.html
2189 bytes
0644
packet-filtering-HOWTO-5.html
1644 bytes
0644
packet-filtering-HOWTO-6.html
3505 bytes
0644
packet-filtering-HOWTO-7.html
35616 bytes
0644
packet-filtering-HOWTO-8.html
1457 bytes
0644
packet-filtering-HOWTO-9.html
2333 bytes
0644
packet-filtering-HOWTO.html
2831 bytes
0644
N4ST4R_ID | Naxtarrr