Set UFW before.rules without restart of server

Posted by enedene on Ask Ubuntu See other posts from Ask Ubuntu or by enedene
Published on 2011-08-05T09:48:20Z Indexed on 2012/11/23 23:21 UTC
Read the original article Hit count: 220

Filed under:
|

I use UFW on my Ubuntu server. Unfortunately there are no rules in UFW to port forward to another machine.
What you need to do is edit /etc/before.rules and put routing commands there, for example

# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]

# Forward traffic from eth0 through eth1.
-A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
-A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.0.200:80
-A PREROUTING -i eth1 -p udp --dport 10090 -j DNAT --to 192.168.0.202:22
-A PREROUTING -i eth1 -p tcp --dport 10090 -j DNAT --to 192.168.0.202:22
-A PREROUTING -i eth1 -p tcp --dport 443 -j DNAT --to 192.168.0.200:443
-A PREROUTING -i eth1 -p udp --dport 443 -j DNAT --to 192.168.0.200:443
-A PREROUTING -i eth1 -p tcp --dport 57626 -j DNAT --to 192.168.0.2:57626
-A PREROUTING -i eth1 -p udp --dport 57626 -j DNAT --to 192.168.0.2:57626
-A PREROUTING -i eth1 -p tcp --dport 3306 -j DNAT --to 192.168.0.200:3306
-A PREROUTING -i eth1 -p udp --dport 3306 -j DNAT --to 192.168.0.200:3306

COMMIT

My problem is that I can't find a way to run new forwarding rules without restarting the server, which I hate to do very much.
So please help me, is there a way?

© Ask Ubuntu or respective owner

Related posts about server

Related posts about ufw