FreeBSD ports – make arguments

Here I list some arguments very useful for the FreeBSD ports.

  • config – Opens up the package’s configuration dialog to turn options on or off.
  • config-recursive – Same as “config,” but also shows dialogs for package’s dependencies.
  • rmconfig – Removes user-specified configuration settings.
  • rmconfig-recursive – Same as “rmconfig” but removes settings for dependencies as well.
  • clean – Removes compiled work files, but not the installed files or downloaded source code.
  • distclean – Removes downloaded source code and work files for the package and its dependencies.
  • install – Installs the package once compiled.
  • deinstall – Removes a package from the system, akin to “pkg_delete.”
  • deinstall-all – Same as “deinstall,” but removes the package’s dependencies too.
  • reinstall – Used to upgrade a Port that first had to be removed with “deinstall”.

Usage example:

# cd /usr/ports/net-p2p/transmission

# make config-recursive

# make install distclean

 

Source: http://blog.zolp.us/2010/09/its-free-free-free-freebsd-part-2.html

Dovecot migration error

We migrated IMAP servers at work and for some reason I was the only one that was affected by a small problem. I couldn’t get my email! The error that would show in the maillog was:

dovecot: IMAP(user): FETCH for mailbox INBOX UID 176705 failed to read message input: Is a directory
dovecot: IMAP(user): Disconnected: BUG: Unknown internal error bytes=473/4475

After looking at several things I eventually saw that my cur directory had some subdirecties named like emails. They were empty, so I went ahead and deleted it and that fixed it!

Just thought I’d let other people know since it’s one of those things that Googling didn’t really give any answers. (Imagine that!)

 

Source: http://notjustlinux.blogspot.com/2009/05/dovecot-migration-error.html

Easy way to convert flash videos to mp3

An easy way to extract and convert the flash video audios (like youtube) to mp3:

ffmpeg -i inpuvvideofile.flv outputaudiofile.mp3

A knockd configuration file

Knockd is a Port Knocking implementation and I really like this one for being quite simple and flexible to work with almost any POSIX Operating System.

There are many ways to implement it, but some can be quite confusing and sometimes even useless if you write it wrong.

I personally like the following kind of configuration for it’s simplicity. I’m going to present you the code and then, after these code lines, I’m going to comment it:

/* Start of the knockd.conf file */
[options]
logfile = /var/log/knockd.log

[opencloseSSH]
sequence = 7000,8000,9000
seq_timeout = 15
command = /sbin/iptables -I INPUT -s %IP% -p tcp –dport 22 -j ACCEPT
cmd_timeout = 10
tcpflags = syn
stop_command = /sbin/iptables -D INPUT -s %IP% -p tcp –dport 22 -j ACCEPT

/* End of the knockd.conf file */

I will not get into deeper details about EACH line, but I will explain you how it works in general for this example.

Basically, knockd will be waiting for the three knock attempts (7000, 8000, 9000). The user has 15 seconds between the first knock (7000) until the last knock (9000). Once the server got those 3 knocks in less than 15 seconds, the iptables will open the port 22. Then you have 10 seconds to establish the connection, after these 10 seconds, the “stop_command” will be launched, which in this case will delete the iptables rule above. Remember, the path “/sbin/iptables” may vary, depending on which Linux distro you are using.

In order to make use of the following configuration scheme, it’s important that you have ESTABLISHED,RELATED rules in your iptables firewalling settings. Like this:

iptables -A INPUT -m –state ESTABLISHED,RELATED -j ACCEPT

Otherwise, you may loose your SSH session after those 10 seconds (even if you connected already).

And, of course, the iptables DROP policy:

iptables -P INPUT DROP

If you are interested about different configuration methods, you should check for the official man page. In the shell: man knockd

I wrote this tutorial based on Gentoo Linux, however, knockd should works in different Linux distros and also with any other *NIX.

References:

http://www.zeroflux.org/projects/knock

http://www.portknocking.org/

DHCP for different subnetworks

It’s quite easy to implement a DHCP configuration but how about if you have different subnetworks with different needs ?

I have at home a server which I use for “playing” with different technologies and also for dns-caching, proxy-caching, etc…

So I have two NIC in it and therefore two different subnetworks.  I did all the routing table but I also needed to edit my dhcpd.conf in order to have it working on different subnets.  Here it goes the conf file:

/*START OF DHCPD.CONF CONFIG FILE*/

authoritative;
ddns-update-style interim;

default-lease-time 900;
max-lease-time 9200;

subnet 192.168.1.0 netmask 255.255.255.240 {
option subnet-mask 255.255.255.240;
option domain-name-servers 192.168.1.1;
option routers 192.168.1.1;
range 192.168.1.3 192.168.1.14;
}   ## On this network, we have the subnet 255.255.255.240, which means, only 14 usable hosts, where the 192.168.1.1 is the gateway for this network and 192.168.1.2 runs the WLAN AP ##

subnet 192.168.0.0 netmask 255.255.255.248 {
option subnet-mask 255.255.255.248;
option domain-name-servers 192.168.0.1;
option routers 192.168.0.3;
range 192.168.0.3 192.168.0.6;
}
##Same thing, but here the netmask is 255.255.255.248, which means only 6 usable hosts, the 192.168.0.3 is the gateway and the 192.168.0.1 and 192.168.0.2 are not here because I use it as static hosts##

/*END OF DHCPD.CONF CONFIG FILE*/

————————

References:

http://en.wikipedia.org/wiki/Subnetwork

How to change MAC address in Linux

It’s quite simple to change the network interface MAC adress on Linux but not everybody knows it, so here it is, with two simple commands we can change our MAC (Media Access Control) address. It should works for other unix based systems as well, but I haven’t tested it yet.

So, as a network-system administrator, someday in your life, you may get a conflicted MAC address, so instead of throwing down your NIC interface to the trash and get a new one, you CAN change the MAC address for a valid one and it’s pretty easy.

So, here we go:

#ifconfig eth0 down hw ether 00:00:00:00:00:05

#ifconfig eth0 up

At this point, your ethernet interface should be working with the new MAC address.

References:

http://en.wikipedia.org/wiki/MAC_address

How to save flash videos on GNU/Linux

I have never tried it on Windows, but it should work in a similar way, I guess.

You probably already heard about those tools which promise to save your youtube (or any other flash video oriented website) videos. Actually you don’t need any third party tool in order to save any flash video.

This is how it works:

—————

#cd /tmp/

#ls -lah

—————

So now you have got your usual temporary files list.

Now go to your favorite web browser and search for an youtube video (or any other flash videp oriented website) and start to load it and wait until it gets fully loaded.

Now back to the tmp directory:

—————

#ls -lah

Flash0GCg9U

—————

You will find out there’s a file in there called “Flash+randomcharacters”, now just copy it to any another directory and feel free to rename the file of course.

Done, now you got the video forever! 😉

Hexadecimal Information – HEX table.

http://www.legacyj.com/cobol/hex.html

Quite useful, especially in the next few years (ipv6 is coming).  🙂

Crontab syntax

Personal note about crontab syntax, from left to right:

Field     Function
1o.     Minute
2o.     Hour
3o.     Month Day
4o.     Month
5o.     Week day
6o.     Command to execute

Values:

Minute     0-59
Hour     0-23
Month day     1-31
Month     1-12
Week day     0-6 (where “0″ means Sunday), 1 means Monday, etc

Sometimes I forget it, so I’m documenting it to myself. Hopefully somebody else will find it useful too. 🙂

How to Convert from Binary to Decimal

Very good “how to” on how to convert Binary numbers to Decimal.

http://www.wikihow.com/Convert-from-Binary-to-Decimal