Linux Network Adapter Bonding

Before you begin take a backup copy of the following files in case you have to set them back to a working state.

/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/ifcfg-eth2
/etc/modprobe.conf

Create a new file /etc/sysconfig/network-scripts/ifcfg-bond0 and add the following to it, using your own ip addresses

DEVICE=bond0
IPADDR=x.x.x.x
NETWORK=y.y.y.y
NETMASK=z.z.z.z
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Modify your /etc/sysconfig/network-scripts/ifcfg-eth1 file and change it to

DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Also modify your /etc/sysconfig/network-scripts/ifcfg-eth2 file and change it to

DEVICE=eth2
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save all of these files.

Add the following lines to the end of /etc/modprobe.conf

alias bond0 bonding
options bond0 mode=0 miimon=1000

Make sure the bonding module is loaded with

modprobe bonding

Then restart the network service

service network resart

You should now see the bond0 nic listed if you run and ifconfig from the command line. Test with less /proc/net/bonding/bond0

Source:

http://itfixed.blogspot.com/2009/02/itfixed-it-for-me-nic-bonding-on-linux.html

http://www.cyberciti.biz/tips/linux-bond-or-team-multiple-network-interfaces-nic-into-single-interface.html

Setup Comcast as Relay Host for Postfix Mail.

root@donkey:~# grep -ir “smtp.comcast.net” /etc/
Binary file /etc/postfix/sasl_passwd.db matches
/etc/postfix/main.cf:relayhost = [smtp.comcast.net]:587
/etc/postfix/sasl_passwd:smtp.comcast.net < username >:< password >

Restart postfix.

!!Run this after modifiying sasl_passwd file

[root@mail postfix]# postmap hash:/etc/postfix/sasl_passwd

Pipe tar file to remote server w/ ssh

jesterj@jesterj-laptop:~$ tar zcvf – donkey* | ssh jesterj@donkey.dnsdojo.com “cat > ~/testarchive3.tar”By far the easiest way to tar a file and send it to a remote location is to simply have two commands on one line. The first to create the tar file, the other to scp the command. In this example, I am not prompted for a passphrase since i have my ssh key saved on the remote server for this user.

Easy:

jesterj@jesterj-laptop:~$ tar -cvf testarchive.tar donkey*; scp testarchive.tar jesterj@remoteserver:~
donkey
donkey1.zip
donkey2.txt
donkey2.zip
donkey.tar
donkey.txt
testarchive.tar                               100%   20KB  20.0KB/s   00:00
jesterj@jesterj-laptop:~$

Pipe the file…More complicated:

jesterj@jesterj-laptop:~$ tar zcvf - donkey* | ssh jesterj@donkey.dnsdojo.com "cat > ~/testarchive3.tar"

source: http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/

Setup proxy w/ Squid

Setup Squid for Linux

Internet Browser Client Setup

Firefox > preferences > settings > Manual Proxy Configuration

IP: (ip for squid server) PORT: 3128 (defautol squid port)

Squid Server Setup

apt-get install squid3
pico /etc/squid3/squid.conf

Add the following…

acl client1 src 10.10.10.2/255.255.255.0
http_access allow client1

Restart squid.

Install SARG reporting tool

sudo apt-get install sarg
edit /etc/squid/sarg.conf
modify squid log file location to:
/var/log/squid3/access.log

run ‘sarg’

look in /var/www/squid-reports for html files of acces logs!

Works!

Record all traffice on port 80

sudo tcpdump -n -i eth0 -s 0 -w output.txt src or dst port 80

Check for open ports/services on remote machine

$ telnet titan.zipcon.net 22
Trying 63.249.22.50…
Connected to titan.zipcon.net.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_5.1p1 Debian-3ubuntu1

View all open ports with Netstat

$ netstat -nta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:6024            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 10.139.68.153:42651     10.139.68.39:22         ESTABLISHED
tcp        0      0 10.139.68.153:51346     64.4.34.126:1863        ESTABLISHED
tcp        0      0 10.139.68.153:44434     206.255.61.214:4228     ESTABLISHED
tcp        0      0 10.139.68.153:38705     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38707     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:40101     64.4.37.39:1863         TIME_WAIT
tcp        0      0 10.139.68.153:38708     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:52217     10.139.10.45:22         ESTABLISHED
tcp        0      0 10.139.68.153:38702     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38709     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38710     205.234.235.90:80       ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN

Accessing MySQL Remotely

Say for example, you have a web page you want to access some data on but the database is located on a different server. To do this you will need to add another user to the mysql.users table and specify the remote location where you are accesing from.

$ mysql -u root -p

mysql>  GRANT ALL PRIVILEGES ON database_name.* TO myUser@host_name IDENTIFIED BY 'pass' WITH GRANT OPTION;

*user ‘%’ for hostname if wanting to accept connections from all hosts.

mysql> Flush priviledges

Next, edit your /etc/mysql/my.cnf file:

Comment the bind-address

#bind-address: 127.0.0.1  //if enabled with disallow connections from a remote host.

Restart mysql:

# /etc/init.d/mysql restart

Test your network speed w/ Iperf

Install iperf

apt-get install iperf

Listen on machine #1

$ iperf -s -P 2 -i 5 -p 5999 -f M

Send packets on machine #2

iperf -c backupserv -P 1 -i 5 -p 5999 -f M -t 60 -T 1

Results:
————————————————————
Client connecting to backupserv, TCP port 5999
TCP window size: 0.02 MByte (default)
————————————————————
[  3] local 192.168.1.5 port 49711 connected with 192.168.1.3 port 5999
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec    562 MBytes    112 MBytes/sec
[  3]  5.0-10.0 sec    562 MBytes    112 MBytes/sec
[  3] 10.0-15.0 sec    561 MBytes    112 MBytes/sec
[  3] 15.0-20.0 sec    561 MBytes    112 MBytes/sec
[  3] 20.0-25.0 sec    562 MBytes    112 MBytes/sec
[  3] 25.0-30.0 sec    561 MBytes    112 MBytes/sec
[  3] 30.0-35.0 sec    561 MBytes    112 MBytes/sec
[  3] 35.0-40.0 sec    561 MBytes    112 MBytes/sec
[  3] 40.0-45.0 sec    561 MBytes    112 MBytes/sec
[  3] 45.0-50.0 sec    561 MBytes    112 MBytes/sec
^C[  3]  0.0-50.8 sec  5707 MBytes    112 MBytes/sec

Getting Airport Express working with Xbox 360

Problem: I have an airport express in my basement but my xbox is located upstairs. I want to avoid running wire upstairs as well as purchasing the $80 wireless adapter for the xbox. Since i have a spare airport express i want to set this up in brigding mode. It does work but there are quite a few steps. See below:

How to configure airport xpress with Xbox

  1. Setup main base station to work correctly
  2. Set channel to ‘1’ or the same on both.
  3. Get the airport id from each wireless unit (not the WAN id) – you will need this later.
  4. On the airport for the xbox make sure you have these settings;
  5. Wireless Mode: Create Wiresless Network (home router)
  6. Connect using: Airport (WDS)
  7. Mac Address: (enter the mac for the main base station)
  8. Configure: Using DHCP
  9. Under WDS Table
  10. enable this base sataion as ‘remote base stations’
  11. Enter airport ID for main base station.
  12. On the main base station go to the WDS tab
  13. enable as main base station
  14. add mac address of xbox airport express

Update both and restart!