Re: Can anyone program perl and fix a script?



On 2008-03-27, Bit Twister <BitTwister@xxxxxxxxxxxxxxxx> wrote:
On Thu, 27 Mar 2008 02:42:06 +0100 (CET), Ohmster wrote:

Hey Bit Twister,

Hey Theo :-)

Your script changes work great, they even show the service that is using
the connection. I put my own NAT IP and my roommate's IP into the hosts
file so I can see at a glance who running what,

Hehehe, saw your post where you were thinking of becoming a system admin.
You are seeing the tip of the iceberg about one of the admin duties.

Well, when you get older and start pushing 50, you tend to want work
where you can make your brains and experience pay off rather than your
back and muscles. Especially with mortgages and bills that just don't
ever stop. :)

Pipe dream I think though. It is quite clear from just trying to
comprehend everything that you have talked about in this post in detail
that I do not have the necessary experience to do any kind of senior
admin job. :(

I know basic stuff, how to setup a network, servers, daemons, mail,
services, and some general admin duties but nothing like a university or
a company like HP might be looking for. I also know where to go for help
and I think that counts for a lot, like here, for one thing, but that
would not get the job done in a timely manner with such an approach.

I had really hoped to learn enough as time went by to maybe get a job in
a small library or something and a small network when I got older but
serious admin, programming, hacks, and scripting is not something you
can just "pick up" and get good at. It takes years of study and hands on
to excell at it. You sure have a tidy pocket of knowledge and experience
under your belt, Bit Twister and have helped me a lot in the past.
Thanks buddy.

This post is so rich in content that I will save it and go back over it
again and again to leech more out of it and trim much of it for my
followup here.

[..]


Yeah, I know you are not a programmer/coder. You can learn to hack out some
code to make the computer work for you, or, let the computer work you.

True.

http://tldp.org/LDP/abs/html/index.html is not a bad read for the
beginning coder.

I love the CLI and shell scripts. This is an excellent reference and
primer, I have it bookmarked now.

You could take that little test script
http://groups.google.com/group/alt.os.linux/msg/3eb055f13124627d
and use it to hack around learning to do perl. Then copy viewer.pl
into your account, and start hacking away at it using some test.data
and the debug switch.

If you were to do a locate \.pm and/or locate \.pl
you would find lots of perl code to look at for examples of a perl commands.

I bookmarked the test script and tried the locate commands, wow, that is
a lot of output, there is quite a bit of perl stuff on my system to
examine, it would seem. I did not know you could use locate that way to
find files by extension. I would have thought "locate *.pm", which seems
to work. How come you use a backslash for a wildcard instead of an
asterisk and is that widely accepted?

I got stuck with a perl application as part of a layoff.
I rushed out and bought O'REILLY The Perl CD Bookshelf which has
Perl in a Nutshell
Learning Perl
Learning Perl on Win32 Systems
Programming Perl
Advanced Perl Programming
Perl Cookbook

All good books, I use Linux In A Nutshell myself.

What follows next is too complex for me to address right now, time to
trim.

[..]

it would be nice to
filter only for Dave or ohmster but the service is my question.
[.]

Too much coding that I don't understand enough to comment on right now,
snipped.

We get domain, http, pop3, gwha-netbios-ssn, and a whole lot of
these, [???] things. Where does this service list come from

getservbyport looks port number by protocol in /etc/services.

Holy crap, that is a huge list of ports and services. What a neat
resource!

and is there a way to add bittorrent to the list of services

grep torrent /etc/services and see what you can see.

Nothing. I would have to lookup bittorrent and see if it sticks to any
standard ports or if it opens tons of random high order ports. If there
were a few, could I edit /etc/services to include the torrent ports?

or is the bittorrent port range to great for that?

If port number is not in /etc/services you get the "[???]" field. :(

Understood.

This is my primary interest in this script, to find out
when my roommie is dogging the entire net with bittorrent so I can warn
him to tone it down or just kill his NAT. I can do something like:
iptables -I FORWARD 1 -s dave -j DROP

Saw an article awhile back about comcast inserting a re[send,set,..]
or something record to automagically throttle their torrent users. :)

He does throttle it down to 100K down and 50K up now. In the beginning
he ran it wide open and even with cablemodem service at 12Mbps down and
380Kbps up, he was still soaking up all the bandwidth, it would take
over 30 second per click on my mouse to see any page or links.

Now he only throttles it up at night if I am asleep he says and turns it
back down again.

and his Internet is gone, restore it with this:
iptables -D FORWARD -s dave -j DROP

Sounds like you need a filter rule in iptables to throttle torrent connection.
As you have seen, it will be a bit of a chore to figure out if it is a
torrent connection or not.

wondershaper is supposed to do that and I do run it now. I am not sure
if it can be configured further, I think it can, to handle QOS and
bandwidth for a specific IP on the LAN. Before wondershaper, FTP
and HTTP downloads would eat my bandwidth so bad that I had to do
something and wondershaper did just the trick. Have you seen the
wondershaper script?
http://lartc.org/wondershaper/
http://freshmeat.net/projects/wshaper/

[..]

Port knocking is too complicated for me to address at this moment, will
study and be back with more questions later, I am sure.

Saw an article on port knocking which would play with iptables rules.
Might want to fetch knock source to see what you can see about the
daemon/service (knockd) and client (knock).
Downside is having to lean another programming language. :(

Is there a way to use conntrack-viewer.pl to show who is using
bittorrent or Azureus to dog my net with torrents?

Saw your answer and it is quite a complicated issue, I can see. The only
other person on my LAN is Dave and I know he would be the one, just
wondering if there were a particular connection or connections that I
might wish to throttle back myself, as the Fedora box *is* the router
and I did it that way purposly instead of using the Linksys for this so
that I could experiment, play, and learn. I did save the post for future
study and will be back and forth with what I learn and more questions.

I will trim it for the sake of posting and thanks again for all of your
terrific help, Bit Twister. A Serious Senior System and Network Admin I
may never be, but I cannot help but to love this stuff and want to learn
more. My next step is probably to move up from Fedora 6 as I do not want
to be left out in the cold with an EOL OS.

[..]
--
~Ohmster | ohmster /a/t/ ohmster dot com
Put "messageforohmster" in message body
(That is MESSAGE BODY, not Subject!)
to pass my spam filter.
.



Relevant Pages

  • Re: how to build Spamassassin
    ... The ports collection is great for certain things. ... it for spam assassin on 4.9 Stable. ... Install Perl 5.8.2 from ports ... Install Spam assassin from ports ...
    (freebsd-questions)
  • Re: devel/imake-4 errors out on mkhtmlindex
    ... I just stumbled over the same problem, it turned out to be a perl problem. ... After installing perl from the ports one should do something like ... installing man pages in config/pswrap... ...
    (freebsd-questions)
  • ANNOUNCE: New module Sys::PortIO 0.1 uploaded to CPAN
    ... I've uploaded a new module Sys::PortIO 0.1 to CPAN. ... to do arbitrary port I/O; on Unix-like systems, ... Revision history for Perl extension Sys::PortIO. ... with parallel, serial, or joystick ports. ...
    (comp.lang.perl.modules)
  • Re: How to update perl on FreeBSD 4.9R (Resolved)
    ... > I did not know you could install Perl module's through the ports. ... > Perl module's via the ports, I got involved in an area which I ... > no mention that you can install Perl modules from the ports, ...
    (freebsd-questions)
  • Re: DBD::Sybase context allocation routine failed
    ... attempting a DB connection using a brand new installation of perl ... perl -MDBI -e 'print DBI- ... but when i attempt to run this stub script: ... The context allocation routine failed. ...
    (perl.dbi.users)