Tuesday, April 28, 2020

Configure a TP-LINK router as a bridge / access point / wifi extender with a WiFi connection (not cable-connected to the main Internet router)

1. Do not touch the main router. There is nothing to configure there.

2. Cable-connect your TP-LINK router (Ethernet) to your computer and go to it's UI by typing the IP, typically 192.168.1.1 or 192.168.0.1

3. Go to Network -> LAN Settings. Change IP address to an IP which is in the LAN segment from your main router, but not in its DHCP range. E.g. if the main router / default Gateway IP is 192.168.1.1 and the DHCP range is 192.168.1.100 - 192.168.1.199 then any IP between 192.168.1.2-192.168.1.99 will do.

4. Disable DHCP server.

5. Click SAVE

6. The router is supposed to reboot. Go to DHCP server and double verify that it is disabled.

7. Go to Wireless -> Basic Settings (or whatever it is called in your model) and switch on "enable WDS". You might need to define specific channel on main router, e.g. 11 and match it on the bridging router by selecting Channel = 11. The same is correct for the Channel Width. Name your WiFi in the way you want, e.g. "my_home_NW_EXT"

8. Hit Scan / Survey button to get the list of available WiFi networks. Select the network broadcasted by your main router and hit "Connect". Enter the password for that network as defined in the main router. Note that it is NOT the password to access the new WiFi network you are defining: "my_home_NW_EXT".

9. GO to Wireless -> Wireless Security where you define the security for your new network "my_home_NW_EXT" and define the password you will use while accessing thi snetwork it could be the same password as for teh bridged network or another one.

10. Reboot the bridged router. Cross your fingers, it should work now.

Wednesday, July 06, 2016

Recovering AWS AMI with lost key pair

If you lost a key pair for the running AMI or an image here is the sequence of steps to recover (ubuntu 14.04 style):
1. For the image, run an instance IN THE SAME AZ where you need your new AMI. If you got a running AMI in another AZ make an image and start the new AMI from that in the AZ where you need your new instance.

2. Once you got a running old AMI in the AZ you need, stop it (do NOT Terminate).

3. Detach volume of the old AMI using AWS Console

4. Start a clean new AMI with the key pair you got.

5. Using AWS Console, attach the detached old AMI volume to the new AMI. AWS will tell you it is mounted at /dev/sdf - NOT SURE IT IS THERE

6. SSH to your new AMI where you attached the old volume


#become a root
sudo -i

#find out where the old volume is attached
sudo lsblk --output NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,LABEL

#it should give you something like
NAME    TYPE SIZE FSTYPE MOUNTPOINT LABEL
xvda    disk   8G                  
└─xvda1 part   8G ext4   /          cloudimg-rootfs
xvdf    disk  14G                  
└─xvdf1 part  14G ext4              cloudimg-rootfs



#create mount point
mkdir /mnt/recovery

#mount the volume - note it is /dev/xvdf1 (with "1" at the end)
mount /dev/xvdf1 /mnt/recovery -t ext4

#copy SSH keys to the old volume. NOTE you will need 'ec2-user' instead of 'ubuntu' in the below pathes if you do it for other OS-s
cat /home/ubuntu/.ssh/authorized_keys > /mnt/recovery/home/ubuntu/.ssh/authorized_keys

#unmount the volume
umount /mnt/recovery/

7. Attach the old volume back to stopped old AMI

8. Now you can kill the new instance and start the old one. You should be able to SSH it with your key pair

Alternatively to steps (7)-(8) you can create a snapshot from the old volume with new key pair, and then create an image from that snapshot. Next, launch a new AMI from that image.

References:
[1]

Wednesday, June 29, 2016

Ubuntu software update can not run due to insufficient disk space

This one-liner does the clean up:
dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | xargs sudo apt-get -y purge

(source)

Tuesday, May 24, 2016

Make Mozilla Thunderbird to properly work with your Google Calendar

Thunderbird uses it's own default "Home" calendar so you need to re-configure it if you want to use your Google Calndar via Lightning plugin.
  1. Manually copy upcoming event from Home calendar to Google calendar (e.g. by creating new events at http://calendar.google.com).
  2. Remove "Home" calendar: "Events and Tasks" -> Unsubscribe selected Calendar -> Home
  3. Download & install "Provider for Google Calendar": https://addons.mozilla.org/en-US/thunderbird/addon/provider-for-google-calendar/, restart Thunderbird
  4. Add your Google calendar: File->New->Calendar->Network Calendar->Google CalendarEnter your email address and then,in the Google authorization window, provide your Google account credentials .
  5.  Last but not least: allow the calendar to accept incoming events and send notifications.Options->Advanced->Config EditorType in the search bar: calendar.google.enableEmailInvitations and click on item to make it 'true'

Sunday, November 29, 2015

Setup a swap file for Linux / Ubuntu

Set up a swap file of 2GB in the "/" folder and attach swap to it

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Test:

sudo swapon -s
free -m

Make your changes permanent:

sudo vi /etc/fstab

Add the following line:

/swapfile   none    swap    sw    0   0

save & close the file.

Twek swapinness (0-100). If near to 0 the kernel  will use swap only it is absolutely necessary.  Values near to 100 mean use more swap and use less RAM.
To see swappiness:
 
cat /proc/sys/vm/swappiness
 
and to change it
 
sudo vi /etc/sysctl.conf 
 
and add at the end of the file

vm.swappiness=10
 
(source) 

Saturday, November 21, 2015

s3cmd for Ubuntu

Installing s3cmd on Ubuntu is really easy:

sudo apt-get install s3cmd
 
and then

s3cmd --configure


Note the utility saves .s3cfg file in your home directory (if not requested differently), so for another user you will have to re-configure it or copy your ~/.s3cfg file and modify it, or run

s3cmd -c ...

Trying it out:

echo "test" ~/test.txt
s3cmd --mime-type='plain/text' put ~/test.txt s3://mybucket 

Explicitly specifying the MIME type avoids s3cmd to do any guesswork trying to determine the file' MIME type.



Friday, November 13, 2015

Qt: "undefined reference to vtable" while inheriting from QObject

Linker' error "undefined reference to vtable" in QT 5.5.1 (Linux-64 g++ 4.8) can be fixed by doing both these things:
a) rm - rf /*
(e.g. /build-myapp-Desktop_Qt_5_5_1_GCC_64bit)
b) moving the QObject definition in .h file next to public / private keyword, i.e. instead of

class Abc : public AnotherClass, QObject

make it

class Abc : public QObject, AnotherClass

Once done, rebuild the project.