computers:firewall_configuration
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
computers:firewall_configuration [2011/08/30 22:27] – [iptables masquerading] chkuo | computers:firewall_configuration [2020/08/16 00:13] (current) – [References] chkuo | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Firewall configuration ====== | ====== Firewall configuration ====== | ||
- | ===== iptables masquerading | + | ===== Source NAT ===== |
- | First enable IPv4 packet forwarding by editing ''/ | + | First enable IPv4 packet forwarding by editing ''/ |
<code bash> | <code bash> | ||
net.ipv4.ip_forward=1 | net.ipv4.ip_forward=1 | ||
</ | </ | ||
+ | Apply by '' | ||
Then add the following lines to ''/ | Then add the following lines to ''/ | ||
<code bash> | <code bash> | ||
- | iptables -t nat -A POSTROUTING -s 192.168.0.0/ | + | # source NAT |
- | iptables -A FORWARD -s 192.168.1.0/ | + | # alter the source address of the packets from the internal network |
- | iptables -A FORWARD -d 192.168.1.0/ | + | Ext_IF=" |
+ | Ext_IP=" | ||
+ | Int_IF=" | ||
+ | Int_Net=" | ||
+ | iptables -t nat -A POSTROUTING -s $Int_Net | ||
+ | iptables -A FORWARD -s $Int_Net | ||
+ | iptables -A FORWARD -d $Int_Net -i $Int_IF | ||
</ | </ | ||
- | ===== Forwarding | + | ===== Destination NAT ===== |
<code bash> | <code bash> | ||
- | # forward ssh to workstation with the internal ip 192.168.1.2 | + | # destination NAT |
- | iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 22 -j DNAT --to-destination | + | # forward ssh to Int_IP if the external IP Ext_IP_2 was used |
- | iptables -A FORWARD -i eth0 -o eth3 -p tcp --dport 22 -j ACCEPT | + | Ext_IP_2=" |
+ | Int_IP=" | ||
+ | iptables -t nat -I PREROUTING -p tcp -d $Ext_IP_2 | ||
+ | iptables -A FORWARD -i $Ext_IF | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Monitoring ===== | ||
+ | <code bash> | ||
+ | sudo iptables -t nat -L | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
===== References ===== | ===== References ===== | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// |
computers/firewall_configuration.1314714454.txt.gz · Last modified: 2011/08/30 22:27 by chkuo