Aleksandar's computer workshop

Let's see what Aleksandar was fixing today.
My findings, tips & tricks related to computers, internet, programming and other stuff I was working with.

Adding extra IP(s) to one network interface in RHL

To permanently add one or more IP's to network interface in RedHat Linux is quite easy if you follow this steps:

  • Go to the /etc/sysconfig/network-scripts/ directory
    cd /etc/sysconfig/network-scripts/
  • Copy the interface file that you want to add the IP to, and give it the same name as the current file, with ‘:0′ added (or :1, :2, depending on how many IPs are on this interface).
    cp ifcfg-eth0 ifcfg-eth0:0
  • Edit the new file, and you only have to change a few things
    > Change IPADDR= to your new IP address
    > Change DEVICE= to add :0
    (depending if this is the 2nd IP on that interface)
    > Remove DHCP_HOSTNAME (or set it to what it needs to be)
    > remove the HWADDR entry
  • Save the file that you just were working on
  • Restart the network interfaces
    /etc/init.d/network restart
  • Done!

 

So here are the examples:

Original file ifcfg-eth0 looks like

# Intel Corporation 82557/8/9 [Ethernet Pro 100]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.5.255
HWADDR=00:06:5B:38:C8:5D
IPADDR=192.168.5.230
NETMASK=255.255.255.0
NETWORK=192.168.5.0
ONBOOT=yes
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes

Config file ifcfg-eth0:0 for second IP looks like:

DEVICE=eth0:0
BOOTPROTO=none
BROADCAST=192.168.5.255
IPADDR=192.168.5.20
NETMASK=255.255.255.0
NETWORK=192.168.5.0
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
ONPARENT=yes

SMTP tar pit feature for Microsoft Windows Server 2003

Tarpitting is the practice of deliberately inserting a delay into certain SMTP communications that are associated with spam or with other unwanted traffic. To be effective, these kinds of communications typically rely on generating a high volume of traffic. By slowing an SMTP conversation, you can dramatically reduce the rate at which automated spam can be sent or at which a dictionary attack can be conducted. Legitimate traffic may also be slowed by tar pitting.

The tar pit feature is available in Microsoft Windows Server 2003 and in several third-party SMTP servers. The tar pit feature in Windows Server 2003 works by slowing all responses that contain SMTP protocol 5.x.x error codes. An administrator can configure the delay that is introduced by the tar pit feature.

Tar pitting affects only anonymous SMTP connections. Authenticated sessions are exempt. Therefore, if you regularly exchange lots of SMTP mail with another organization,
and you find that tar pitting is affecting that traffic, you can bypass tar pitting for that organization by authenticating SMTP communications.

More details you can find here:
http://support.microsoft.com/kb/842851

Properly Capturing Identity Values

When inserting a row into a database table that contains an identity column, I need a way to capture the identity value generated by the database engine after it inserts the row into this table. What can I use to capture this value while also making sure this value is accurate?

SQL Server provides three different functions for capturing the last generated identity value on a table that contains an identity column:
1) @@IDENTITY
2) SCOPE_IDENTITY()
3) IDENT_CURRENT(‘tablename’)

But which should you use? Check out this article for more information:
http://www.mssqltips.com/tip.asp?tip=1385

How to change Name Server (DNS Client) Settings under Linux

In order to be able to use conical names you have to use name servers (also called DNS servers) which will convert some name into IP address. I will here show you where are configuration files under Linux

Edit /etc/resolv.conf which can like this:
nameserver 192.168.1.1
nameserver 10.0.0.138

Also you might hardcode some IP's in hosts file. It looks like this:
127.0.0.1 localhost.localdomain localhost
194.109.6.67 ns.xs4all.nl

To have your new settings valid you have to restart the computer or do this in command line which will restart all your network services and devices:

/etc/init.d/network restart

If you are connected with SSH be patient connection will be restored.