Wednesday, August 28, 2013

NATting with iptables on Ubuntu

/etc/sysctl.conf:
net.ipv4.ip_forward = 1

sysctl -p /etc/sysctl.conf

/etc/init.d/networking restart

# list rules
iptables -L
iptables -t nat -L
iptables -t nat -L -n -v

# flush rules & NATs
iptables --flush
iptables --table nat --flush

iptables -t nat -A PREROUTING -p tcp –-dport 80 -j DNAT –-to-destination 192.168.22.122:80
iptables -t nat -A PREROUTING -p tcp –-dport 3306 -j DNAT –-to-destination 192.168.22.122:3306
iptables -t nat -A PREROUTING -p tcp –-dport 2222 -j DNAT –-to-destination 192.168.22.122:22

iptables -t nat -A POSTROUTING -j MASQUERADE


####### Auto Loading Rules at System Start-up #######

#1 save rules to file
iptables-save > /etc/iptables.rules

#2 find interfaces
iwconfig
ifconfig

#3 edit config file
vi /etc/network/interfaces

#4 add line to relevent interface (iface eth1)
pre-up iptables-restore < /etc/iptables.rules

Thursday, January 10, 2013

See all connected users to MySQL

SHOW PROCESSLIST;

Caveat: you need to execute this command as a user with the PROCESS privilege in order to see all of the other users who are connected to the database. Otherwise, you see only those server threads that belong to the same user as the one making the query.

Thanks to : David Harper - Cambridge, England

Reference: http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html

Wednesday, January 2, 2013

Proxying via Apache

Inside the <virtualhost> section add following.
<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>

ProxyRequests Off
ProxyPreserveHost Off

ProxyPass /proxy/ http://www.newurl.com/
ProxyPassReverse /proxy/ http://www.newurl.com/