Categories
Networking

Run Chrome on different network interfaces in Ubuntu

If you have two different internet providers running in single PC, most of time you would like to split the usage between different network interface / adapter.

For instance, you want one browser for browsing and others for downloading / uploading activities. There are several solution to run multiple ethernet network devices like bind-address, firejail and others that may not working easily in Ubuntu

Quick solution for this is to leverage open-source project : https://github.com/JsBergbau/BindToInterface

First, clone the project

git clone https://github.com/JsBergbau/BindToInterface

Second, compile it (make sure to have gcc already installed)

gcc -nostartfiles -fpic -shared bindToInterface.c -o bindToInterface.so -ldl -D_GNU_SOURCE

Third, get your network interfaces information with sudo ifconfig (you can install this as well) and try to get interfaces name. In my case, I have two: enpf0 and enpf1.

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17xxxx  netmask 255.255.0.0  broadcast 172.17.255.255xxx...

enpf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xx.xx  netmask 255.255.255.0  broadcast 
        ....

enpf1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xxxx  netmask 255.255.255.0  broadcast         ....

Now, here is a quick way to run Google Chrome or Firefox with different network interfaces or ethernet with public internet access.

Go inside the github project (or you can copy the .so file) and run this command. Replace enpf1 with your own network interface

BIND_INTERFACE=enpf1 LD_PRELOAD=./bindToInterface.so /usr/bin/google-chrome-stable 

Now you successfully open the google-chrome with specific network interface.

Categories
Networking

Solve WordPress NGINX (13: Permission denied)

A quick step to solve this error from WordPress and NGINX

crit *2 stat() index.php" failed (13: Permission denied) wordpress

Make sure to create permission to the hosted folder by

chmod +x /path/website

If the problem still exists, try to add www-data into your user group

gpasswd -a www-data ubuntu

If the page is not found, try to restart your php-fpm services

sudo service php8.1-fpm stop
sudo service php8.1-fpm start
Categories
Networking

Install Numpy with OneAPI MKL for AMD in Ubuntu

NumPy uses libraries like BLAS, LAPACK, BLIS, or MKL to execute vector, matrix, and linear algebra operations. It’s acknowledged that Intel with MKL (Math Kernel Library) is quite more mature in this math operation than other libraries due to resources and experiences.

If you want to leverage Intel OneAPI MKL as backend for your Numpy, especially on Intel chip (or AMD if you want to try), here are a quick step for installation in Ubuntu (I use the latest ubuntu 23.04 Lunar Lobster).

First, download the required softwares

sudo apt install build-essential python3-pip python3 python3-dev libomp-dev

A context, libomp-dev will help you to avoid the error “Solve bmkl_intel_thread.so.2: undefined symbol: omp_get_num_procs” when importing the numpy libraries in the python interpreter.

Second, we will install the Intel Base-kit: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?operatingsystem=linux&distributions=aptpackagemanager.

Or follow the commands below

Categories
Networking

Migrate WordPress to Upgraded Ubuntu AWS Server

I move WordPress from Ubuntu Server 21.04 to 23.04 with several easy steps. Here are the quick guideline on how to migrate WordPress safely without breaking

First, Backup all necessary data
Open your terminal and start with your home path ~/

sudo mysqldump -u root -p yourdb > db.sql

Second, Compress etc, home and any folder needed

sudo zip -r /etc etc.zip
sudo zip -r /home/ubuntu

Transfer the file to the new server. If you need to use pem-key and using either windows or linux, use SCP to transfer pem-key from local computer to old-server. This is needed so you can transfer file from old to new server

scp -i .\your-key.pem -r .\your-key.pem ubuntu@your-ec2-server-ip:/home/ubuntu

Now your key pem is exists in home path in old server. Its time to transfer the whole zip files backup to the new server home path

scp -i your-key.pem *.zip ubuntu@your-new-server-EC2:/home/ubuntu/

Once its done, you just need to extract the folder and replace whatever needed configuration and databases to the new server.

If you encountered by permission denied (13) on NGINX,

/php/php8.0-fpm.sock:", host: "www. com"
2023/04/23 16:31:33 [crit] 17224#17224: *28 stat() "/home/ubuntu/" failed (13: Permission denied), client: 182.253.152.107, server: .com, request: "GET / HTTP/1.1", host: "www. .com"
2023/04/23 16:31:33 [crit] 17224#17224: *28 stat() "/home/ubuntu/" failed (13: Permission denied), client: 182.253.152.107, server: .com, request: "GET / HTTP/1.1", host: "www..com"
2023/04/23 16:31:33 [error] 17224#17224: *28 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 182.25352.107, server: .com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.0-fpm.sock:", host: "www..com"

the quickfix solution

sudo gpasswd -a www-data ubuntu
chmod o+x YOUR-WEBSITE-FOLDER
sudo service php8.1-fpm restart
sudo service nginx restart

Done! Now you can smoothly migrate WordPress from the old ubuntu server to the new ubuntu server without problem. The last step is to change the IP-address in NS. If you are using AWS Route 53, just change the IP address in the record and you are ready to go!

Categories
Networking

Setup Router following another main Router IP Address

In this case, I’m using Asus RT-AC59U V2 connected to main router from Internet provider. Before i’m explaining how to do it, the reason why I need to have the same IP address class across network, is to make sharing or ping between them easily.

First, I just realized any computer in the network able to ping computer A that connected to main router via LAN. Meanwhile, computer B that connected from another router can’t received ping from computer A.

After checking on “ipconfig”, I found both machine A and B have different IP address class eg: 192.168.50.xxx and 192.168.4.xxx. This is why cant ping between computer.

Fyi, I’m using both Ubuntu Server and Windows 10 in this network. Where for Windows 10, the firewall already turn off and sharing mode in LAN settings already on.

The Solution

I decided to reset my Asus router. After read through the Asus product documentation https://dlcdnets.asus.com/pub/ASUS/wireless/RT-AC59U/E15565_RT-AC59U_UM_v2_WEB.pdf I found the culprit is rely on operation mode.

So, my router by default have operation mode as “Wireless router mode”. in WAN settings, it’s received IP from main router. But, when other PC connect to this Asus router, it will have 192.168.50.xx.

Then, I change my ASUS operation mode into Access Point mode and problem solved! All the machine that connected to my router will following the same IP address as main router!

Categories
Networking

Ubuntu Listening Who Ping me

Often we want to know who others IP address that currently send ping to our server. To detect this, can use this script

sudo tcpdump -i <YOUR-ETH-DEVICE) icmp and icmp[icmptype]=icmp-echo

#sudo tcpdump -i eth2 icmp and icmp[icmptype]=icmp-echo
Categories
Networking

Mount NTFS shared folder Windows in Ubuntu write access

If you want to mount your shared partition or folder in Windows 10 to be accessible from Ubuntu server, you can use CIFS. Here is the step

sudo mount -t cifs -o user=YOUR-UBUNTU-USERNAME,username=YOUR-WINDOWS-USERNAME,password=YOUR-WINDOWS-PASSWORD,dir_mode=0777,file_mode=0777 //YOUR-WINDOWS-IP-ADDRESS/PATH-FOLDER /media/MOUNT-PATH

Categories
Networking

Setup Harvester Farmer Chia with Ubuntu and Windows

Harvesters works as connecting the plots into Farmer via SSL remotely. Single harvesters can contains many plots. And yes, many harvesters can connect to single Farmer, which easier for you decouple from storage depedencies.

If you confuse what is Farmer? This is what farmer looks like

This is the main software that you are running to farming your plots. Farmer must only works in single machine as your only gateway to Chia Network.

Next, what is Harvester? It’s services that running separately than Main software. Ideally, you run this service into separate machine where you store your plots.

So, imagine I have main machine that maximum 20TB capacities and running the Farmer. Also, I have another machine with 120TB plots storage and connected via LAN to the main machine.

Usually, you can share folder so main machine can access the storage. With harvester, you can avoid the hassle in giving permission and make it more secure. This are the step to do it

Categories
Networking

Solve Driver Power Failure Windows 10

Suddenly I see this Windows 10 Blue screen of Death “Driver Power Failure” often. No idea why this appear because seems my hardware is fine. To solve this problem, we can do three steps:

First, do the scan health and restore health. Go to Windows Menu -> Open command prompt -> using Administrator mode

Then go type

DISM.exe /Online /Cleanup-image /scanhealth
DISM.exe /Online /Cleanup-image /Restorehealth

This step should 80% fixing your problem. To handle another edge cases, you can disable power trigger to your system.

Second, go to Device Manager by right click Windows Start Menu. Go to Network Adapter, choose you Ethernet -> Properties -> Power Management. Then disable the Allow the computer to turn off this device to save power.

Categories
Networking

Fixing Foreign Status Dell Poweredge R730 via iDRAC

When you remove the HDD from the bay, the log will be showing information like :

Drive 4 is removed from disk drive bay 1.

When we put back into tray, the log will be showing:

Drive 4 is installed in disk drive bay 1.

Sometimes, the status in Storage showing foreign state. This probably the HDD is part of RAID virtualdisk that detached accidentally. To fix this issue, go to iDRAC setting.

Go to Controller

Click “Setup” Menu and scroll down to Foregin Configuration. Your hdd will be show here. Then just click import to fix it

Idrac foreign state