1

I'm new to Ubuntu, I'm using Ubuntu 18.04 on my server.

I have a questions that maybe some Master Ubuntu Expert in this forum could kindly help me out.

  • Is IPtables command line are different with Ufw command line ?
  • If so, how could I translate bellow command line into Ufw command line ? (I couldn't have GUI Ufw since I'm using Ubuntu 18.04 server version without GUI).

//VPS\

sudo iptables -P FORWARD DROP
sudo iptables -A FORWARD -i eth0 -o wg0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -i wg0 -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT     

//VPS-port 80

sudo iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.4.2 
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 80 -d 192.168.4.2 -j SNAT --to-source 192.168.4.1  

//VPS-port 443

sudo iptables -A FORWARD -i eth0 -o wg0 -p tcp --syn --dport 443 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 192.168.4.2     
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 443 -d 192.168.4.2 -j SNAT --to-source 192.168.4.1

//HomeServer\

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.4.2    
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 192.168.4.2    
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 80 -d 192.168.4.2 -j SNAT --to-source 192.168.4.1   
sudo iptables -t nat -A POSTROUTING -o wg0 -p tcp --dport 443 -d 192.168.4.2 -j SNAT --to-source 192.168.4.1
  • 1
    Where did you come up with those iptables commands? If you're sure that's exactly what you need, you can just use iptables without bothering with ufw. – rm-vanda Apr 30 '19 at 14:13
0

Is IPtables command line are different with Ufw command line ?

Yes definitely, see man iptables and man ufw

how could i translate bellow command line into Ufw command line ?

You can't since ufw doesn't have all the functionalities you need for your case. However, ufw is using iptables under the hood. So you can add iptables rules to ufw. See for example : IP masquerading - Ubuntu server guide

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.