{"id":222,"date":"2006-10-08T01:47:44","date_gmt":"2006-10-07T22:47:44","guid":{"rendered":"http:\/\/www.void.gr\/kargig\/blog\/?p=222"},"modified":"2006-10-12T03:33:59","modified_gmt":"2006-10-12T00:33:59","slug":"intracom-netroute2-hacks","status":"publish","type":"post","link":"https:\/\/www.void.gr\/kargig\/blog\/2006\/10\/08\/intracom-netroute2-hacks\/","title":{"rendered":"Intracom netroute2 hacks"},"content":{"rendered":"<p>Since I now own my own dsl I am using an intracom netroute2 as a dsl modem\/router. What really rocks about it is that it is linux (busybox) based, so one can change a lot of how stuff works in it. The bad news about it is that Intracom no longer produces it! The good news is that someone might be able to get some second hand of those modems really cheap. I wonder who was the idiot to stop the production of those modems in Intracom&#8230;<\/p>\n<p>Anyway&#8230;I&#8217;ll post here some of the changes I did to it . I am using firmware version 577 so everything I say here might not work on older ones.<\/p>\n<p>A) Fix ntp.<br \/>\nThe modem\/router on boot reads \/etc\/date and changes the date according to that file. My version dated from april 2006 made the modem on boot to think that it was april.  It is easy to fix this using an ntpclient cronjob. So create a file inside \/etc\/cron.d\/ named cron_ntpclient and paste the following inside it:<br \/>\n<code>0,15,30,45 * * * * root \/usr\/bin\/ntpclient -s -h ntp.grnet.gr > \/dev\/null 2&gt;&1<\/code><br \/>\nThis will sync the time on the modem every 15minutes.<br \/>\nIf you want to be even more accurate like I do check out the following. I had noticed that my modem takes about 1 min and 20 secs from the time I plugged it in till the time it got IP from my ISP. So if I could make it to ntp sync immediately after getting an IP it would be pretty cool. So, I edited \/etc\/date and replaced the contents of the file with the following:<br \/>\n<code>091918002006<\/code><br \/>\nThis makes the modem to set its date at 18:00 19-September-2006.<\/p>\n<p>Then change the cron script to this:<br \/>\n<code>02,15,30,45 * * * * root \/usr\/bin\/ntpclient -s -h ntp.grnet.gr > \/dev\/null 2&gt;&1<\/code><\/p>\n<p>Now the modem syncs the date on the next minute after it gets IP from the ISP. This is really helpfull if you use syslog (read on for this).<\/p>\n<p>BEWARE though that BEFORE you reboot you MUST run \/etc\/init.d\/checkpoint. This command is VITAL! It saves the changes you do inside the configuration files so they are not overwritten on the reboot by the stuff inside \/etc-ro\/.<\/p>\n<p>B) This version has snmpd installed but not started by default. So let&#8217;s make it start when netroute2 boots.<br \/>\nThe only thing that needs to be done for this is add an entry inside \/etc\/net.conf. You need to add somewhere around the end an entry like this:<br \/>\n<code><br \/>\nSNMP_RO_COMMUNITY=YOUR_SNMP_COMMUNITY<br \/>\n<\/code><\/p>\n<p>Change &#8216;YOUR_SNMP_COMMUNITY&#8217; with a password of your choice. You can use vi to do it. Run \/etc\/init.d\/checkpoint afterwards to save your changes.<\/p>\n<p>You can now reboot Netroute2 and if you type &#8216;ps aux&#8217; on it&#8217;s shell you will probably see something like this:<br \/>\n<code>  408 root        840 S   \/sbin\/snmpd -c \/etc\/snmpd.conf -l \/dev\/null<\/code><br \/>\nThat means snmpd is now listening for connections. You can now monitor the traffic with mrtg if you want from another PC. I&#8217;ll post my own mrtg.conf for the netroute2 but it does not necessarily mean that it will work for you too. It depends on which ethernet devices you use to connect it to your network. I use eth0.<br \/>\nHere&#8217;s the mrtg.conf for my netroute2: <a href='http:\/\/void.gr\/kargig\/blog\/wp-content\/netroute2mrtg.conf.gz' title=''>netroute2-mrtg.conf<\/a> <\/p>\n<p>Use it with your other mrtg scripts, I won&#8217;t tell you how here&#8230;if you don&#8217;t know&#8230;google for it. It&#8217;s realy simple. Here&#8217;s a HOWTO from the Gentoo Wiki <a href=\"http:\/\/gentoo-wiki.com\/HOWTO_SNMP_and_MRTG_Made_Easy\">HOWTO_SNMP_and_MRTG_Made_Easy<\/a> for the lazy ones.<\/p>\n<p>C) Syslog activation.<br \/>\nA syslog daemon is also included but not started in netroute2. It is primarily thought to be logging remotely to another machine. But netroute2 has 10Mb of free space at \/tmp&#8230;so we can make it store some logs there. On reboot these logs are lost, so it&#8217;s only usefull if you netroute is on a UPS or if you want to monitor what&#8217;s going on while netroute is working. It&#8217;s not for watching what happened and your netroute2 crashed. If you want such behaviour you must activate remote syslog logging, and if you want that you must be able to easily find out how to do it, you don&#8217;t need my advice \ud83d\ude42<\/p>\n<p>First of all fire up vi and edit \/etc\/syslog.conf. Change all entries that start with \/var\/log to \/tmp\/var\/log\/. Then go find \/etc\/init.d\/rc-syslog and edit it with vi. Find line 13. It should say something like this:<br \/>\n<code><br \/>\n                \/bin\/echo \"Invalid Syslog Server IP!\"<br \/>\n                exit 1<br \/>\n<\/code><\/p>\n<p>Change it to:<br \/>\n<code><br \/>\n                \/bin\/echo \"Invalid Syslog Server IP!\"<br \/>\n                \/bin\/echo \"Logging Locally!\"<br \/>\n                mkdir -p \/tmp\/var\/log\/<br \/>\n                #exit 1<br \/>\n<\/code><\/p>\n<p>What happens here is this, the script searches \/etc\/net.conf for a variable named SYSLOG_SERVER_IP. If it finds it it enables remote syslogging to that IP (damn!.. I&#8217;ve said it), but we want to enable local logging so we have to bypass it. We first create the \/tmp\/var\/log directory and then put a &#8220;#&#8221; in front of the exit command so the script does not stop when it can&#8217;t find SYSLOG_SERVER_IP.<\/p>\n<p>\/etc\/init.d\/checkpoint again&#8230;.reboot&#8230;and if all went fine if you &#8220;ps aux&#8221; you should see something like:<br \/>\n<code><br \/>\n  166 root        336 S   \/sbin\/syslogd<br \/>\n  169 root        264 S   \/sbin\/klogd -c 3 -x<br \/>\n<\/code><\/p>\n<p>If you cd to \/tmp\/var\/log you can find the log files. You can more them, tail them, grep them, whatever&#8230;it&#8217;s up to you now.<\/p>\n<p>D) Enable iptables logging.<br \/>\nNetroute2 features iptables firewalling and tc for QoS!!! You can easily modify the firewall script to make it suit your needs better. What I am going to describe here is how to make iptables log to syslog so you can view what is being blocked by iptables.<\/p>\n<p>First thing you have to do is go to the web interface (yes it IS sloooooooow but who cares ? You won&#8217;t be needing much anyway \ud83d\ude42 ), go to &#8220;Wan Connections&#8221; and click on Firewall. Go where it says &#8220;Expert Configuration&#8221; (don&#8217;t you already feel l33t ? heh) and add a dummy line like this:<br \/>\n<code><br \/>\niptables -A INPUT -i ppp0  -p tcp  --dport 135 -j DROP<br \/>\n<\/code><code><br \/>\nClick on apply and wait a bit until it refreshes the firewall webpage.<br \/>\nThis line, even it is totally useless (if you know a bit of iptables and see the rest of the firewall listing I am sure you already know why),  it will force netroute2 to create a seperate firewall file for your connection and not use its default one.<\/p>\n<p>Now go back to netroute2's shell. If you don't know\/remember the name of your connection do an<br \/>\n<\/code><code>ls \/etc\/wan\/current\/<\/code><code><br \/>\nand it will show you it's name.  Then go to \/etc\/wan\/firewall\/ and edit the file with your connection name. You will see inside it the full listing of iptables rules.<\/p>\n<p>Lines 25-27 should a bit like these:<br \/>\n<\/code><code><br \/>\n:INPUT ACCEPT [0:0]<br \/>\n:FORWARD ACCEPT [43:9993]<br \/>\n:OUTPUT ACCEPT [73:33579]<br \/>\n<\/code><br \/>\nAdd below the last one a line like the following:<br \/>\n<code><br \/>\n:LOG_DROP - [0:0]<br \/>\n<\/code><\/p>\n<p>Around line 65 there should be something like this:<br \/>\n<code><br \/>\n-A INPUT -i ppp0 -j DROP<br \/>\n<\/code><\/p>\n<p>change it to:<br \/>\n<code><br \/>\n-A INPUT -i ppp0 -j LOG_DROP<br \/>\n<\/code><\/p>\n<p>Then finally find the last line of the file that says COMMIT and add above it these two lines:<br \/>\n<code><br \/>\n-A LOG_DROP -j LOG<br \/>\n-A LOG_DROP -j DROP<br \/>\n<\/code><\/p>\n<p>The editing is finished. DON&#8217;T forget to \/etc\/init.d\/checkpoint&#8230;.reboot and you are ready.<\/p>\n<p>If you had previously enabled syslog logging correctly you can do a:<br \/>\n<code> tail -f \/tmp\/var\/log\/kernel.log<\/code><\/p>\n<p>and if you firewall blocks something you might see a line that looks like this:<br \/>\n<code>Sep 24 02:16:57 (none) kernel: IN=ppp0 OUT= MAC= SRC=XX.XX.XX.XX DST=YY.YY.YY.YY LEN=48 TOS=0x00 PREC=0x00 TTL=128 ID=30976 DF PROTO=TCP SPT=3935 DPT=135 WINDOW=65535 RES=0x00 SYN URGP=0<br \/>\n<\/code><\/p>\n<p>You can change all the other &#8220;-j DROP&#8221; settings inside your firewall config with &#8220;-j LOG_DROP&#8221; to gather more information about what gets dropped. If you do that though it might be necessary to refine your \/etc\/syslog.conf to create more accurate log files..Which log files keeps what kinds of logs&#8230;play with it.<\/p>\n<p>E) Netroute has some advanced commands that are not inside the PATH.<br \/>\nLook for some very interesting binaries like tcpdump, tc, etc inside \/usr\/sbin<\/p>\n<p>F) Public key auth with dropbear:<br \/>\non client machine:<br \/>\n<code><br \/>\nssh-keygen -t rsa<br \/>\nscp .ssh\/id_rsa.pub root@netroute.ip:<br \/>\n<\/code><br \/>\non netroute2:<br \/>\n<code><br \/>\nmkdir .ssh<br \/>\nmv id_rsa.pub .ssh\/authorized_keys<br \/>\nchmod 400 ~\/.ssh\/authorized_keys<br \/>\nchmod 700 ~\/.ssh<br \/>\n\/etc\/init.d\/checkpoint<br \/>\n<\/code><\/p>\n<p>If everything is done properly you will now be able to ssh from your client to netroute2 without password.<\/p>\n<p>I wish I could find more of these great machines. 2 Ethernet ports, usb, serial console, 2 FXS, it&#8217;s own small sip compatible PBX &#8230; what else can one need ? A usb port for an external disk and a torrent client probably&#8230; \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since I now own my own dsl I am using an intracom netroute2 as a dsl modem\/router. What really rocks about it is that it is linux (busybox) based, so one can change a lot of how stuff works in it. The bad news about it is that Intracom no longer produces it! The good [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"footnotes":""},"categories":[3,8],"tags":[],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-linux","category-networking"],"aioseo_notices":[],"views":7406,"_links":{"self":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/comments?post=222"}],"version-history":[{"count":0,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}