Archive for the 'Linux Support' Category

SBDavid

How to redirect port using IPTABLES

How to redirect port using IPTABLES

You can redirect the port in IPTABLES using the prerouting parameter.

Following is the command you can use to redirect the traffic of port 8080 to port 80.

$ /sbin/iptables -t nat -I PREROUTING -p tcp –dport 8080 -j REDIRECT –to-port 80
$ /etc/init.d/iptables save
$ /etc/init.d/iptables restart

You can change the ports in the above command according to your need.

Tcpdump command to monitor the SMTP activity from a IP or range of IP.

The tcpdump is a useful utility to monitor the network activity in the server.
You can monitor the SMTP activity to find out the mail account used by spammer.

tcpdump -i eth0 -n src 192.168.1.4 \or dst 192.168.1.4 -w smtp.tcpdump -s 2048

The above command will monitor the SMTP activity from the IP address 192.168.1.4 and will log to the file smtp.tcpdump.

Please use the following command to monitor a range of IP

tcpdump -i eth0 -n src net 219.91.0.0/16 \or dst net 219.91.0.0/16 -w smtp.tcpdump -s 2048

The above command will monitor the range of IP starting with 219.91. You can use less or Wireshark to analyze the dump file. You need to replace the network device with your network device EG : venet0:0 in a VPS.

SBDavid

Basic Requirements for cpgsd

Basic Requirements for cpgsd

* gcc
* Perl 5+
* OpenSSL (including headers, usually in a separate package called something like openssl-devel or ssl-dev)
* Net::SSLeay perl module
* IO::Socket::SSL perl module
* IPC::Run perl module

configure the sshd server to disable password login and enable keys.

First - We need to generate a pair of keys.

ssh-keygen -v -t rsa -b 2048

and then

cat /home/buddy/.ssh/buddy_rsa.pub > /home/buddy/.ssh/authorized_keys

Editing the config file /etc/ssh/sshd_config

vi /etc/ssh/sshd_config

login to remote server using the password to configure the sshd server to disable password login and enable keys.

vi /etc/ssh/sshd_config

And then edit…

PermitRootLogin no
#Disable Login password
#PasswordAuthentication no
ChallengeResponseAuthentication no
#Allow forwarding yes
AllowTcpForwarding no

# Uncomment ‘PasswordAuthentication no’ line only after making sure that the key authentication is working properly.
# Disabling root login is recommended anyway, though not useful after disabling login password.
# Allow forwarding is not recommended for multi user hosting envirnoment where keys could be exposed. Anyway, we should only allow it if we intend to forward keys from server to server but keep all our keys on the local machine.

SBDavid

SSH tunnel for Mysql

SSH tunnel for Mysql

This will open a tunnel, listening on localhost:3308 and forwarding everything to yourdomain.com:3306

ssh -L 3308:yourdomain.com:3306 username@yourdomain.com

And then

mysql -u username -p -h 127.0.0.1 -P 3308 databasename

« Prev - Next »