Step1: Editing this file directly:
[root@PTUDServer3 MySQL]# vim /etc/sysconfig/iptables # Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *nat :PREROUTING ACCEPT [331:34227] :POSTROUTING ACCEPT [4:240] :OUTPUT ACCEPT [4:240] -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535 -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535 -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE COMMIT # Completed on Sat Mar 14 11:38:50 2015 # Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *mangle :PREROUTING ACCEPT [339:34627] :INPUT ACCEPT [12:1736] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [8:400] :POSTROUTING ACCEPT [8:400] -A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill COMMIT # Completed on Sat Mar 14 11:38:50 2015 # Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT # Completed on Sat Mar 14 11:38:50 2015 |
To open port 3306 insert this line between *filter and COMMIT:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT |
Result, I insert like this:
# Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *nat :PREROUTING ACCEPT [331:34227] :POSTROUTING ACCEPT [4:240] :OUTPUT ACCEPT [4:240] -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535 -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535 -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE COMMIT # Completed on Sat Mar 14 11:38:50 2015 # Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *mangle :PREROUTING ACCEPT [339:34627] :INPUT ACCEPT [12:1736] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [8:400] :POSTROUTING ACCEPT [8:400] -A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill COMMIT # Completed on Sat Mar 14 11:38:50 2015 # Generated by iptables-save v1.4.7 on Sat Mar 14 11:38:50 2015 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT COMMIT # Completed on Sat Mar 14 11:38:50 2015 |
Save this file via press Esc, typewq
Step 2: Next, you need to restart iptables:
[root@PTUDServer3 MySQL]# service iptables restart iptables: Setting chains to policy ACCEPT: filter mangle na[ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ] |
Finish, Goodluck!
0 komentar:
Post a Comment