Nätverk

Set up OpenWRT to connect and use a PPTP VPN.

Running Linux on a router is just like magic, wouldn't you agree? If not - try it!

The other day I wanted to set up a VPN connection for some of my devices at home. And since I only could have one device connected at the time, I figured it would be simpler to connect my router and then have the VPN connected on any of my connected devices at home.

I run OpenWRT on my TP-Link WR1043ND and i found it to be really easy to set up a VPN connection, and use it to tunnel all of the data by default. Here's how:

(To begin with, you need a router running OpenWRT, a VPN account somewhere (your own server, IPredator, whatever) that has support for PPTP, and access to your router.)

  1. Login to your router.
  2. Click System > Software > Update lists.
  3. Press "Avaliable packages" and search for PPTP.
  4. Install these packages: (you might have to do the search again in avaliable packages, for each package)
    luci-proto-pptp, kmod-pptp and pptp
  5. Once these packages are installed, move on to Network and click "Add new interface".
  6. Give it a name, perhaps the name of the service.
    Set the protocol to PPtP and click Submit.
  7. Fill in the form using the info and credentials from your VPN service. Then press Save.
  8. It is a good idea to let the VPN connection to be set up immediately, so set it to connect during book in Advanced settings. Save.
  9. The new VPN interface should now connect itself, but there is still one thing left to do: add it to a Firewall Zone.
    Editing your VPN interface, click on Firewall Settings and add it to WAN.
  10. Surf! To doubble check if the connection is working you could try a site like this one: ipaddresslocation.org

3G modem not re-connecting in OpenWRT?

Since I reflashed my router (TP-Link WR1043ND) I found out that I didn't have to use my own usb_serial script to get my Huwaei E182e modem to work in OpenWRT (still running RC5) - it just worked out of the box!

The thing was though, that the modem sometimes would disconnect, and would not re-connect using "ifup wan" anymore. After authentication, the modem would hangup and I had to reboot the whole router - which could get rather irritating.

Today, I gave myself time to explore this issue, instead of using a ping script that rebooted the router if not answering, and I found this thread:
https://forum.openwrt.org/viewtopic.php?pid=159749#p159749

The user, mforkel had a solution that I think would resolve my issue (I'm actually posting this before I've tried it, since I'm not at home at the moment).

  1. Logon to your router using SSH or Telnet.
  2. Edit /etc/config/network. eg:
    $ nano /etc/config/network
  3. Now locate the wan interface, which is using your modem:
    config 'interface' 'wan'
            option 'ifname' 'ppp0'
            option 'proto' '3g'
            option 'service' 'umts'
            option 'apn' 'data.cell.com'
            option 'pincode' '1234'
            option 'device' '/dev/ttyUSB0'
            option 'username' 'danielholm'
            option 'password' 'inspire;)'
  4. Now add this row:
    option 'pppd_options' 'debug noipdefault'
  5. Save and reboot. Good to go!

Generera SSH-nycklar.

SSH är ett säkert sätt att administrera div. enheter och maskiner över terminal och kommandon. Men i standardutförande så används oftast bara lösenord. Ett alternativ till detta, som ökar säkerheten ytterligare, är att använda sig av publika nycklar. Dessa kan genereras för ett helt system på den dator, såväl som för enskilda användare.

Jag använder nycklar till alla mina servrar, routrar, mobiler, osv. och det tycker jag att du med ska göra. I detta korta avsnitt tänkte jag bara visa hur man genererar en såan nyckel för att du senare ska kunna använda den vid div. tillfällen och tjänster.

Det hela är väldigt enkelt:

Öppna en terminal och kör:
$ ssh-keygen -t rsa -b 4096


En förfrågan om vart du vill spara nycklarna kommer att dyka upp. Använd standardplatsen om du inte vet vad du gör.
Du kommer få en ytterligare förfrågan om passphrase. Detta är ett lösenord man har för att kunna låsa upp och använda nyckeln. Gör här som du själv vill, men det är säkrare att ha en passphrase.

Gratulerar, du har nu ett nyckelpar i .ssh/id_rsa.pub. Alltså mappen .ssh som finns i din hemmap och i den, filen id_rsa.pub

Mer info om SSH, nycklar osv. finner du här: https://help.ubuntu.com/community/SSH/OpenSSH/Keys

UPDATE: Lade till antalet bitar för extra säkerhet.

Slipp felmeddelanden och (fusk) ordna Avahi med .local nätverk.

Jag är nog knappas ensam när det gäller problem med .local-nätverk. Man får bla. en varning vid inloggning angående detta och det ger även en del problem med Avahi, vilket man kan använda till Bonjour, fil- och skrivardelning, service discovery mm.

Problemet ligger egentligen hos ens ISP som inte tillhandahåller ordentliga domäner för sina kunder, i detta fall .local domänen so inte stöds.

Det finns dett fusk som både får meddelandet att sluta visas och att faktiskt kunna använda tex. Bonjour igen.

Redigera filen /etc/default/avahi-daemon och ändra;
AVAHI_DAEMON_DETECT_LOCAL=1
till
AVAHI_DAEMON_DETECT_LOCAL=0

Man kan även köra:
$ sudo avahi-daemon

Då ordnar det sig för denna uppstart, men du kommer få köra det vid varje uppstart.

Subscribe to Nätverk