How to Configure Your NIC’s IP Address
You need to know all the steps needed to configure IP addresses on a NIC card. Web site shopping cart applications frequently need an additional IP address dedicated to them. You also might need to add a secondary NIC interface to your server to handle data backups. Last but not least, you might just want to play around with the server to test your skills.
This section shows you how to do the most common server IP activities with the least amount of headaches.
Determining Your IP Address
Most modern PCs come with an Ethernet port. When Linux is installed, this device is called eth0. You can determine the IP address of this device with the ifconfig command.
[root@bigboy tmp]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:08:C7:10:74:A8 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x1820 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:787 errors:0 dropped:0 overruns:0 frame:0 TX packets:787 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:82644 (80.7 Kb) TX bytes:82644 (80.7 Kb) wlan0 Link encap:Ethernet HWaddr 00:06:25:09:6A:B5 inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:47379 errors:0 dropped:0 overruns:0 frame:0 TX packets:107900 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:4676853 (4.4 Mb) TX bytes:43209032 (41.2 Mb) Interrupt:11 Memory:c887a000-c887b000 wlan0:0 Link encap:Ethernet HWaddr 00:06:25:09:6A:B5 inet addr:192.168.1.99 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:11 Memory:c887a000-c887b000 [root@bigboy tmp]#
Debian / Ubuntu Network Configuration
Many of the core Fedora / Redhat commands and configuration files covered in this chapter can be used in Debian based operating systems, but there are some key differences.
The /etc/network/interfaces File
The main network configuration file is the /etc/network/interfaces file in which all the network interface parameters are defined. The file is divided into stanzas:
The auto Stanza
The auto stanza defines the interfaces that should be automatically initialized when the system boots up.
The mapping Stanza
This stanza maps configuration parameters for an interface depending on the output of a script. For example, on booting the script could prompt you as to whether your laptop Linux system is at home or work with the mapping statement using the answer to configure the appropriate IP address.
By default the much simpler hotplug system is used which assumes that the interfaces will have only one purpose. Typical hotplug configurations simply assign each physical interface with a matching logical interface name (nick name).
mapping hotplug script grep map eth0 eth0 map eth1
HOWTO OpenVPN setup(excelent)
1. First of all get a few additional repos, If you already have your repos setup, skip this step
If you have Fedora 3, follow these steps, http://stanton-finley.net/fedora_cor…notes.html#Yum
If you have Fedora 4, follow these steps, http://stanton-finley.net/fedora_cor…notes.html#Yum
If you have Fedora 5, follow these steps, http://stanton-finley.net/fedora_cor…notes.html#Yum
if you have CentOS, follow the “additional third party CentOS repos” http://www.osresources.com/11_6_en.html Then issue these commands, each line is a new command, anything beginning with “#” are comments so dont try to execute those.
# yum update # yum install openssl openssl-devel # openssl and openssl-devel may be installed already… so don’t worry
2. Right, now you want to install OpenVPN, here are the commands,
# yum install openvpn -y // Now check that it works # service openvpn start # service openvpn stop
3. A few things to setup before you can make certificates, issue these commands,
# find / -name "easy-rsa" // you should get an output like this # /usr/share/doc/openvpn-2.0.7/easy-rsa // Now, make a copy of the easy-rsa directory, to /etc/openvpn/ ( make sure you #have put the right version number in i.e. mine was -2.0.7, change if needed) # cp -R /usr/share/doc/openvpn-2.0.7/easy-rsa /etc/openvpn/ # cd /etc/openvpn/easy-rsa # chmod 777 * # mkdir /etc/openvpn/keys
HOWTO VPN over SSH and tun
Do it with a Script
Introduction
The following script will let you start a full featured VPN using SSH and tun.
Requirements
* OpenSSH with tun support on both sides (tested Debian 4.3 on server, Gentoo 4.5 on client) * Root access on both sides * Allowed root access and tunnel on server side:
File: /etc/ssh/sshd_config
PermitRootLogin yes PermitTunnel yes TCPKeepAlive yes # Not required but makes things much more stable. This is default now
* Compiled ‘tun’ module on both sides * Loaded ‘tun’ module on server side * Allowed ARP proxy (required only for accessing client from within the private network)
Howto create Loop Device on REDHAT, CENTOS or FEDORA
This mini howto explain how to create more loop device on your operating system.You need to create more loop device in some case like encrypted file system or HVM xen virtualization. By default there are 7 devices available, named /dev/loop0 through to /dev/loop7 .
INFORMATIONS
You can find the loop device like that :
# ls -al /dev/loop* brw-r----- 1 root disk 7, 0 Mar 19 09:34 /dev/loop0 brw-r----- 1 root disk 7, 1 Mar 19 09:34 /dev/loop1 brw-r----- 1 root disk 7, 2 Mar 19 09:34 /dev/loop2 brw-r----- 1 root disk 7, 3 Mar 19 09:34 /dev/loop3 brw-r----- 1 root disk 7, 4 Mar 19 09:34 /dev/loop4 brw-r----- 1 root disk 7, 5 Mar 19 09:34 /dev/loop5 brw-r----- 1 root disk 7, 6 Mar 19 09:34 /dev/loop6 brw-r----- 1 root disk 7, 7 Mar 19 09:34 /dev/loop7
The creation of the loop device is very simple but you have 2 options for this creation one is without reboot and the other one is with a reboot.
ConvertMboxToMailbox
Converting from UNIX mbox/mailbox to Maildir – postfix, procmail, Squirrelmail, uw-imap and cyrus-imap
This guide discusses transforming a system from the traditional mbox/mailbox format to the more advanced Maildir format.
I assume you are using the postfix mailer – if not, you will probably want to change over to postfix first or some of this material may not be relevant.
Make a backup
Before commencing, backup your entire system.
Stop the mailer
You do not want any mail coming in while doing the conversion. You should also stop any programs that automatically generate mail locally.
# /etc/init.d/postfix stop
Get the necessary tools
If you are running Debian, this command will get everything you need:
# apt-get install mb2md
Convert each users mail
For each user on your system:
# su daniel $ cd ~ $ mb2md -m $ mb2md -s mail $ exit # mv /var/spool/mail/daniel /var/spool/mail/daniel.preMaildir # mv ~daniel/mail ~daniel/mail.preMaildir
NOTE: The second mb2md command is only needed if the user has a directory ~/mail where they store mbox/mailbox format mail folders.
Later on, you will want to delete the .preMaildir versions to recover disk space. Before you do so, make sure everything is working fine.
find — how to replicate a complex directory and file structure
Sed – An Introduction and Tutorial
Bruce Barnett
Last update: Wed Apr 16 20:55:07 EDT 2008
Thanks to Keelan Evans, Fredrik Nilsson, and Kurt McKee for spotting some typos.
Thanks to Wim Stolker and Jose' Sebrosa as well.
Thanks to Olivier Mengue.
Thanks to Andrew M. Goth.
Thanks to David P. Brown.
Copyright 2001,2005,2007 Bruce Barnett and General Electric Company
All rights reserved
You are allowed to print copies of this tutorial for your personal use, and link to this page, but you are not allowed to make electronic copies, or redistribute this tutorial in any form without permission.
real world unix/linux FIND usage
find . -type f -size +10000 -exec ls -al {} \; find . -atime +1 -type f -exec mv {} TMP \; # mv files older then 1 day to dir TMP find . -name "-F" -exec rm {} \; # a script error created a file called -F find . -exec grep -i "vds admin" {} \; find . \! -name "*.Z" -exec compress -f {} \; find . -type f \! -name "*.Z" \! -name ".comment" -print | tee -a /tmp/list find . -name *.ini find . -exec chmod 775 {} \; find . -user xuser1 -exec chown -R user2 {} \; find . -name ebtcom* find . -name mkbook find . -exec grep PW0 {} \; find . -exec grep -i "pw0" {} \; find . -atime +6 find . -atime +6 -exec ll | more find . -atime +6 -exec ll | more \; find . -atime +6 -exec ll \; find . -atime +6 -exec ls \; find . -atime +30 -exec ls \; find . -atime +30 -exec ls \; | wc -l find . -name auth* find . -exec grep -i plotme10 {}; find . -exec grep -i plotme10 {} \; find . -ls -exec grep 'PLOT_FORMAT 22' {} \;