1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hosts file use possible in Alchemy?

Discussion in 'Sveasoft Firmware' started by likuidkewl, Jun 27, 2005.

  1. likuidkewl

    likuidkewl Network Guru Member

    I know *nix variants are capable of this but is the sveasoft alchemy 3.37.6.8sv?

    If anyone has got it working a little info on how is greatly appreciated, it must have something to do with the rc file, but I am new to this.
     
  2. davidsonf

    davidsonf Network Guru Member

    Yes it can be used, as can a few other files in the /etc directory that are actually symbolic links to the ramdisk mounted as /tmp. The reason for the symbolic link is to make the file actually writeable. The trick is not writing it, but getting whatever you write to survive a reboot. That's where the startup file comes in!

    Using telnet, login to get a command line. Using vi, make an appropriate hosts file. You can edit /etc/hosts or /tmp/hosts, as it is the same thing.

    You can test it by using "ping hostname" to see if it works.

    When it is as you want it to be, do this:
    Code:
        nvram set hosts="$(cat /tmp/hosts)"
        nvram commit
    That will save your /tmp/host file to nvram! You can then retrieve it with this command:
    Code:
        nvram get hosts > /tmp/hosts
    And to get that to happen each time the system is booted, it has to be put into /tmp/.rc_startup. So edit that file too. Add that line, and then save it basically the same way:
    Code:
        nvram set rc_startup="${cat /tmp/.rc_startup)"
        nvram commit
    At that point you should be able to reboot the router and find that /etc/hosts is restored when you login again.

    Other files you might want to initialize the same way are /tmp/.profile, and /tmp/resolv.conf.

    Here are some useful things you could try in your /tmp/.profile to init the root login shell:
    Code:
    export PS1='\[\033[36m\]\h:\u \w >\[\033[m\]'
    hostname WRT54G
    export TZ=AKST9AKDT
    alias ll='/bin/ls -alF'
    alias ls='/bin/ls -axF'
    alias ntp='ntpclient -lsh us.pool.ntp.org'
    alias help='wl -h 2>&1 |more'
    You'll want to set that for your timezone and use a different hostname. (Actually, the hostname should be set in the startup file, but I put in there just to show how, and it will work ok if you leave it in the profile.)
     
  3. likuidkewl

    likuidkewl Network Guru Member

    Wow, thanks for such an explanatory post, and not a RTFM. It is greatly appreciated. I will post the outcome once all is said and done, again thanks!
     
  4. likuidkewl

    likuidkewl Network Guru Member

    nvram comes back and states that the argument list is too long???

    //Edit//
    Seems my file size is too big.
     
  5. likuidkewl

    likuidkewl Network Guru Member

    Sorry to keep bumping this but here is where I am stuck:

    I have
    1.) imported the host file with wget
    2.) saved it to nvram, after removing imported junk from file with vi
    3.) opened .rc_startup in vi and added this at the bottom
    Code:
    nvram get hosts > /tmp/hosts
    4.) saved .rc_startup to nvram
    Code:
    nvram set rc_startup="$(cat /tmp/.rc_startup)"
    committed

    upon reboot the .rc_startup has 33 lines now compared to 17 and 16 of them are a copy of the previous lines, but it will not stick even after it is committed to nvram. the editted line, which I put in is there but that is line 33, so my question is where are these 16 lines coming from? Is .rc_startup called from somewhere else also that is being appended at boot?

    I guess I should also ask if what I am trying to do will work, I am trying to make this hosts file block ad sites I regularly run into, as the 6 sites are not enough. I would like to do this here at the router and not the PC, this keeps it much cleaner, and I wouldn't have to do this to all the pc's one by one.

    TIA
     
  6. davidsonf

    davidsonf Network Guru Member

    How big is this file???

    Try it with only two or three entries, just to make sure that is the problem. Note that nvram is finite, and if you have a jffs filesystem enabled that is also taking up space. But otherwise it is pretty hard to imagine... :)
     
  7. likuidkewl

    likuidkewl Network Guru Member

    the hosts file was saved fine, it was a little large :), but now the problem is with the .rc_startup having 33 lines half of that being the same thing. Plus I don't even know if this is going to work the way I want it too, Argh...

    Thanks for your help, :)
     
  8. davidsonf

    davidsonf Network Guru Member

    I'm not sure how you got the extra lines into .rc_startup, but it was most likely something you did in vi. Regardless, you can edit them out easily enough.

    However, what you want to accomplish will not work. The only effect the hosts table on the router has is on programs actually run on the router. It is not a filter for packets passing through.
     

Share This Page