eko_hermiyanto has asked for the wisdom of the Perl Monks concerning the following question:

I have a project to write a cgi code to change ip address of internet users on my network. The users will login with web interface and they will be assigned with fixed ip address based on their login name and password. For example:
Username : Jason
Password : 1234
if he correctly input his username and password, his computer will be assigned ip address bla.bla.bla.bla.

For doing this thing, I discovered Net:IP, but it seems that I can not use it to change ip address of my internet users.

In addition, of course my internet users have their own internet setting(network setting) on their computers. This is because I am working in an apartment, and my computer users sometime bring their laptops into their office and their computers assigned with their offices' setting.

Then, if the users use DHCP setting, can I change it into fixed ip address with perl code? And then assigned the ip address with perl code too? How I can do this with perl? Or would you mind for referencing me into the right modules or packages please.

I am a perl beginner and this project is very complicated to me.

Thank you very much for the help.

Eko Hermiyanto

Edit: g0n - formatting tags

  • Comment on assigning ip on internet users on my network

Replies are listed 'Best First'.
Re: assigning ip on internet users on my network
by brian_d_foy (Abbot) on Nov 23, 2006 at 21:14 UTC

    A CGI script isn't going to be able to change the IP address of computers which access it (unless you really want to get into weird stuff with setuid scripts and net hacking). You want to work through existing protocols, such as DHCP, to do that sort of thing. It's going to be a lot less painful that way, too. :)

    Is the goal to let people use your home network temporarily? It's better to start by telling us what you need to do rather than how you're trying to solve it. :)

    Perhaps you want something like NoCatAuth. It provides a captive portal through which users can authenticate and then gain network access. It's even built into some routers already.

    Update: It seems to me that you have some reading to do about network administration. If your goal is to track users, grab the MAC when they get an address. The MAC uniquely identifies the computer. You might also suggest to your boss to get someone to help you set it up. Again, focus on the goal and not the method :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
      Dear brian and zaco, thank you very much for your reply. Here, in this apartement where I am working now has been already set-up network. Then, the bos asked me to write code which will assign ip address into internet users each time they get connected to the network. And this ip addresses are specific into certain rooms. For example, room 1 has ip address bla.bla.bla.bla. I don't know how to solve this problem with perl. I am new into this what many people call as mighty programming language. But, I just figured out, that I can write a web interface in which users will input their username and password, and then their computers will be assigned with ip addresses which have been decided to be used in their room by a little perl CGI script. The scheme is username:password:ip-address. My bos only wants every rooms has their own ip address. Then, my bos able to monitor the access of the internet for each room. Because if each room has its own ip address, then we will know what's room which has a given ip address. This kind of thing can not be implemented in DHCP. So, this is the problem exactly. Thank you very much again for your help. It's very much useful for newbie just like me.
        When you talk about assigning IP addresses, you are definitevely in the realm of DHCP.

        Is this a wired or wireless network ?

        It appears that what you are looking for is a combination of DHCP, 802.1x, and dynamic VLAN assignment.

        All these topics are beyond the scope of discussion at this website.

        With a better problem description, I'm sure perlmonks would be happy to help.

             "A closed mouth gathers no feet." --Unknown

Re: assigning ip on internet users on my network
by Zaxo (Archbishop) on Nov 23, 2006 at 20:32 UTC

    Perl can be used to do any sort of system work. You don't say what sort of network management you use besides DHCP, so it's hard to suggest code for this. Anything you can do from the shell can be done from perl with system and friends.

    What do you do about a multiuser box?

    To successfully enter a web interface, the user's network interface has to already have an IP address that works. Why change it?

    In fundamental terms, IP's represent network interfaces, not machines or users. It sounds like you're putting the cart before the horse somewhere to generate this project.

    After Compline,
    Zaxo

      Users will be connected through the internet with concentrators which in turn connected into routers. In this case, we are using a pc with Mikrotik RouterOS.
Re: assigning ip on internet users on my network
by jbert (Priest) on Nov 24, 2006 at 09:06 UTC
    As a technical person, you can sometimes have a difficult situation when someone comes to you and says "I want you to write/make something which does X".

    Sometimes "doing X" seems very hard or has other downsides ("but if we do X, then we will have to re-login 10 times a day" - 'no matter, X is more important').

    Often, the person asking you "to do X" only wants it done because they have a requirement Y - something they want to happen and they have decided that the way to achieve that is to do X. The problem can be that the person making this decision may have made it for bad reasons. Perhaps they don't know enough about other ways of achieving Y which are easier. Perhaps they have a dislike or mistrust of a certain way of doing things based upon incorrect or out of date knowledge.

    But if you are able, through a combination of personal skills and asking the right questions, to both discover Y and also (which is often harder) persuade the person asking you that perhaps you could try achieving Y by doing Z, then you can avoid doing X at all. This does of course mean that you need the knowledge and experience to think up Z, as well.

    If you are able to achieve this combination of personal skills and problem analysis, you could probably call yourself a business analyst, but this is a skillset I think is beneficial to all/most technical people.

    In your particular case, from what you have said in other replies, it is possible that Y is "be able to monitor what person A was accessing on the internet". It is possible your boss thinks it is necessary to change the IP address of each person so that he knows which IP address people are using. But it might be the case that instead you simply need to record the current IP address (check out %ENV hash in your CGI script) and time of each person as they log-in, perhaps in a database or file. You could then write some code which reads this and works out which IP address was being used by person A at time T. This might be enough to meet your requirement.

    I don't know enough about your situation, but what you are trying to do is sufficiently unusual that you might want to consider a different solution.

Re: assigning ip on internet users on my network
by Firefly258 (Beadle) on Nov 25, 2006 at 01:42 UTC
    I think if you ultimately want to monitor activity on IP addresses, the right way to go about it would be to implement something along the lines of RAS with RADIUS/TACACS or a VPN.

    The above mentioned technologies were invented for this very reason.