| 154 | = Networking-related odds and ends = #net |
| 155 | Various non-experimental network setups, usually done for convenience. |
| 156 | == NAT box with `ufw`. == |
| 157 | source: https://nowhere.dk/articles/tip_nat_with_ubuntus_ufw_firewall |
| 158 | `ufw` is your standard Linux firewall, and comes with Ubuntu server edition. Turning a multi-interface Linux box into a router is a matter of the following steps: |
| 159 | 1. configure IP forwarding |
| 160 | edit /etc/default/ufw : |
| 161 | {{{ |
| 162 | DEFAULT_FORWARD_POLICY="ACCEPT" |
| 163 | }}} |
| 164 | and /etc/ufw/sysctl.conf : |
| 165 | {{{ |
| 166 | net.ipv4.ip_forward=1 |
| 167 | }}} |
| 168 | 2. set up IP masquerading in `ufw` |
| 169 | edit /etc/ufw/before.rules, just after the header : |
| 170 | {{{ |
| 171 | # nat Table rules |
| 172 | *nat |
| 173 | :POSTROUTING ACCEPT [0:0] |
| 174 | |
| 175 | # Forward traffic through ppp0 - Change to match you out-interface |
| 176 | -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE |
| 177 | |
| 178 | # don't delete the 'COMMIT' line or these nat table rules won't |
| 179 | # be processed |
| 180 | COMMIT |
| 181 | }}} |
| 182 | The address block after -s should match the address block behind the NAT firewall. |
| 183 | |
| 184 | 3. restart ufw: |
| 185 | {{{ |
| 186 | sudo ufw disable && sudo ufw enable |
| 187 | }}} |
| 188 | |
| 189 | ---- |