2023년 3월 8일 수요일

IP 가 여러개인 Linux 에서 디폴트로 사용중인 IP 주소 찾기

 ip route get 8.8.8.8

이러면 8.8.8.8 로 가기 위한 기본 경로를 알려준다

ip route get 8.8.8.8

8.8.8.8 via 1.227.225.1 dev eth0  src 1.227.225.48

    cache  mtu 1500 advmss 1460 hoplimit 64


src 다음에 나오는 IP가 디폴트로 쓰이는 IP가 된다. 


이것만 추출하려면

 ip route get 8.8.8.8 | head -1 | cut -d' ' -f8

또는

ip route get 8.8.8.8 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p'


ip route get 8.8.8.8 | head -1 | awk '{print $7}'


2023년 2월 13일 월요일

Volumio VMWare esxi 설치

Volumio Image 를 rufus 등을 이용하여 USB Stick 으로 플래쉬하고,  VMWare USB Stick 으로 부팅하면 

아래와 같은 메시지후 진행되지 않는다

findfs: unable to resolve 'UUID=****************...'


이는 USB Stick 이 disk drive 처럼 인식되지 않기 때문이다.


SATA disk 형태로 16GB 정도 만든후

live Linux CD/DVD 등을 준비 하여 Linux Live CD/DVD 로 부팅한다.


터미널을 열어 root 쉘을 얻는다

nc 를 통해 124번 포트를 open 한후 들어오는 데이터를 /dev/sda 로 받는다

nc -l -p 1234 > /dev/sda



다른 서버나 리눅스등을 이용해서 위에 nc 를 open 한 Linux CD/DVD 서버 IP를 확인후 
 Volumio 이미지를 nc를 이용하여 네트워크 전송을 한다

 nc -w 3 192.168.0.77 1234 < Volumio-3.423-2023-01-24-x86_amd64.img

이제 live Linux CD/DVD 등을 제거한후 /dev/sda 로 부팅하면 Volumio 셋업 화면을 볼수 있다.


2022년 5월 23일 월요일

ASUS OpenVPN 에서 client config 내부 라우팅 안될때

OpenVPN Route for MacOS

내부 IP 대역이 192.168.1.0/24 이라고 가정하고

OpenVPN Client IP를 10.8.0.6 으로 할당 받았다고 가정

sudo route add -net 192.168.1.0 -netmask 255.255.255.0 10.8.0.6


그러나 매번 VPN 접속마다 Route 가 틀어져서 번거로운 일임 따라서 아래의 client vpn config에 마지막줄에 Route 명령어를 넣어준다

route 192.168.1.0 255.255.255.0 


2022년 4월 11일 월요일

curl 에서 https hostname 방식으로 접근

 

curl 에서는 가상호스트 등을 테스트 할때 hostname 방식으로 접근할때

HTTP 일땐 --header 에 Host 헤더를 이용하여 호스트 명을 명시해서 가능하나

ex) 

hexcode.example.com 이 호스트명이고 

IP 가 10.101.81.200 이라고 가정할때 

curl --header "Host: hexcode.example.com" http://10.101.81.200


HTTPS 일땐 --header 에 Host 헤더를 이용하기가 어렵다. 

아래와 같이 한다.

ex)

hexcode.example.com 이 호스트명이고 

IP 가 10.101.81.200 이라고 가정할때 

curl --resolve hexcode.example.com:443:10.101.81.200 https://hexcode.example.com


또는 전통적인 방법으로 /etc/hosts 를 수정하여 사용하기도 하자

2021년 9월 8일 수요일

dmesg 사람이 보기 쉽게

CentOS6 dmesg 에 찍히는 시간이 uptime 이후 시간이여서 알아보기 힘들다 아래와 같이 uptime - 현재시간 구해서 보면 편하다


 dmesg_human () {

    $(type -P dmesg) "$@" | perl -w -e 'use strict;

        my ($uptime) = do { local @ARGV="/proc/uptime";<>}; ($uptime) = ($uptime =~ /^(\d+)\./);

        foreach my $line (<>) {

            printf( ($line=~/^\[\s*(\d+)\.\d+\](.+)/) ? ( "[%s]%s\n", scalar localtime(time - $uptime + $1), $2 ) : $line )

        }'

}


CentOS7 에서는 간단히 -T 옵션을 사용할 수 있다.

dmesg -T

2021년 8월 15일 일요일

OneDrive version 삭제

꽁자 5TB OenDrive 파일 버전 관리로 인해 용량이 줄어들때 일일히 버전 파일을 삭제 하기란 매우 힘든일이다.

PowerShell  에서 아래와 같이 한다.

SharePoint Online Client Components SDK 를 먼저 설치한다.

https://www.microsoft.com/en-us/download/details.aspx?id=42038


아래와 같이 PowerShell 스크립트를 실행하면 모든 버전 파일이 for loop 을 돌면서 삭제된다.

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

   

#Config Parameters

$SiteURL= "https://yoursharepont-my.sharepoint.com/personal/yourid_domain_com/"

$LibraryName="Documents"


#Setup Credentials to connect

$Cred = Get-Credential

$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

  

    #Setup the context

    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)

    $Ctx.Credentials = $Cred

  

    #Get the web and Library

    $Web=$Ctx.Web

    $List=$web.Lists.GetByTitle($LibraryName)

   

    $Query = New-Object Microsoft.SharePoint.Client.CamlQuery

    $Query.ViewXml="<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FSObjType'/><Value Type='Integer'>0</Value></Eq></Where></Query></View>"

    $ListItems = $List.GetItems($Query)

    $Ctx.Load($ListItems)

    $Ctx.ExecuteQuery() 

    

    #Loop through each file in the library

    Foreach($Item in $ListItems)

    {      

    Start-Sleep -s 1

        #Get all versions of the file

        $Ctx.Load($Item.File)       

        $Ctx.Load($Item.File.Versions)

        $Ctx.ExecuteQuery()

        Write-host "Processing Item:" $Item.file.Name

  

        #Delete all versions of the file

#        If($Item.File.Versions.count -gt 0)

#        {

            $Item.File.Versions.DeleteAll()

            $Ctx.ExecuteQuery()

            Write-host -f Green "All Versions deleted on "$Item.file.Name

Start-Sleep -s 3

#        }

    }   


Windows11 Update 후 windowsdefender 를 열려면 새 앱이 필요합니다.

PowerShell 관리자 모드로 창을 연후

Get-AppxPackage Microsoft.SecHealthUI -AllUsers | Reset-AppxPackage

이러면 다시 windowsdefender 데시보드 가 열림

2021년 3월 2일 화요일

Asuswrt Merlin dnsmasq 를 이용하여 시간대별 youtube lol 차단

우선 /jffs/scripts 를 사용할수 있게 config에서 설정

Support for these scripts stored under /jffs/scripts/ must be enabled, under Administration -> System on the webui:


아래 등록 스크립트 작성
cat /jffs/scripts/add.sh
#!/bin/sh
echo "address=/youtube.com/127.0.0.1"  > /jffs/configs/dnsmasq.conf.add
echo "address=/prod.kr.lol.riotgames.com/127.0.0.1" >> /jffs/configs/dnsmasq.conf.add
service restart_dnsmasq


아래 삭제 스크립트 작성

cat /jffs/scripts/del.sh

#!/bin/sh

echo "" > /jffs/configs/dnsmasq.conf.add
service restart_dnsmasq

실행 권한 주기
chmod 755  /jffs/scripts/add.sh
chmod 755  /jffs/scripts/del.sh

크론탭에 등록하기
예제는 24:00 에 차단 07:00 에 차단해제

cru a add_dnsmasq "0 0 * * * /jffs/scripts/add.sh"
cru a del_dnsmasq "0 7 * * * /jffs/scripts/del.sh"

참고 
크론탭 등록 방법
https://www.cyberciti.biz/faq/how-to-add-cron-job-on-asuswrt-merlin-wifi-router/
커스텀 dnsmasq 사용 방법
https://github.com/RMerl/asuswrt-merlin.ng/wiki/Custom-domains-with-dnsmasq


2021년 1월 17일 일요일

android app 에서 32bit , 64bit 선택 설치

 2019 년 8월 1일부터 Google Play에 게시되는 앱은 64bit 아키텍처를 지원해야 합니다.

그런데 64bit app 에서 일부 불안정하여 32bit app 을 필요로 할때가 있습니다.

디폴트로 아키텍처가 64bit면 64bit 모드로만 설치가 됩니다.

아래와 같이 adb를 --abi 옵션을 이용하여 선택적으로 설치가 가능합니다.

지원되는 abi 자세한 설명에 대해선 아래 사이트를 참조 합니다.

https://developer.android.com/ndk/guides/abis?hl=ko


아래는 인텔 아키텍처 32bit 전용으로 설치할 경우 입니다. 

32bit 인텔 아키텍처는 x86 입니다. 

adb install --abi x86 example.apk

4652 KB/s (35631753 bytes in 7.479s)

        pkg: /data/local/tmp/example.apk

Failure [INSTALL_FAILED_NO_MATCHING_ABIS]

위와같이 32bit 를 지원하지 않는 app 경우에 INSTALL_FAILED_NO_MATCHING_ABIS 에러가 납니다. 

adb install --abi x86 example.apk

4012 KB/s (83017609 bytes in 20.207s)

        pkg: /data/local/tmp/example.apk

Failure [INSTALL_FAILED_ALREADY_EXISTS]

이미 앱이 설치가 되어있는 경우에 위와 같이 INSTALL_FAILED_ALREADY_EXISTS 설치가 미리 되었다는 에러가 나는데 그럴땐 재설치 옵션 -r 를 사용합니다.

adb install -r --abi x86 example.apk

4330 KB/s (83017609 bytes in 18.720s)

        pkg: /data/local/tmp/example.apk

Success


2021년 1월 7일 목요일

2021년 1월 6일 수요일

Linux 커널 업그레이드후 vmware 모듈 문제

 Linux 커널 업그레이드 후 vmware 재실행시 모듈이 설치 되지 않았다고 다시 나온다 새 커널 버전에 맞게 모듈을 재 빌드 해야 하며 아래 명령어로 재빌드한다

vmware-modconfig --console --install-all

2020년 7월 28일 화요일

윈도우 한영 전환 레지스트리 모음

101Key_Type3


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters]
"LayerDriver KOR"="KBD101C.DLL"
"OverrideKeyboardIdentifier"="PCAT_101CKEY"
"OverrideKeyboardType"=dword:00000008
"OverrideKeyboardSubtype"=dword:00000005
"LayerDriver JPN"="kbd101.dll"


Shift + Space 전환

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters]
"PollingIterations"=dword:00002ee0
"PollingIterationsMaximum"=dword:00002ee0
"ResendIterations"=dword:00000003
"LayerDriver JPN"="kbd101.dll"
"LayerDriver KOR"="kbd101c.dll"
"OverrideKeyboardType"=dword:00000008
"OverrideKeyboardSubtype"=dword:00000005
"OverrideKeyboardIdentifier"="kbd101c.dll"
"KeyboardFailedReset"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,\
                   00,00,00,00,\ 
                   03,00,00,00,\
                   72,00,38,E0,\ 
                   71,00,1D,E0,\
                   00,00,00,00


2020년 4월 13일 월요일

rclone systemd 방식으로 마운트


https://forum.rclone.org/t/rclone-auto-mount/6353/14 에서 참고 했습니다.

# vi /etc/systemd/system/rclonemount.service

[Unit]
Description=RClone Service
After=network-online.target
Wants=network-online.target


[Service]
Type=notify
ExecStart=/usr/bin/rclone mount --allow-other --vfs-read-chunk-size 16M --buffer-size 2G onedrive: /mnt/onedrive
ExecStop=/bin/fusermount -uz /mnt/onedrive
Restart=on-abort
User=users
Group=users

[Install]
WantedBy=default.target


# systemctl daemon-reload
# systemctl enable rclonemount
# systemctl start rclonemount

2020년 4월 4일 토요일

vmware guest 에서 ubuntu / debian 계열 사운드 소리가 작을때

vmware guest 에서 ubuntu / debian 계열 사운드 소리가 작을때

vmware 에서 내장사운드로 Ensoniq AudioPCI  계열로 잡히는데 소리가 매우 작습니다.
Windows 계열은 정상적으로 소리가 나네요

AlsaMixer 를 이용해서 PCM 부분 볼륨을 방향키로 이동해서 높혀주면됩니다.
나올때는 ESC 키 입니다.

명령어는 alsamixer 입니다.


2020년 3월 15일 일요일

ubuntu 데스크탑을 Windows 원격 데스크톱 으로 접속하기

sudo apt install xrdp

그렇지만 Windows 원격 데스크톱으로 로그온 하면
"색상 프로파일을 만들려면 인증이 필요합니다"
메시지가 무한 반복된다.


아래와 같이 권한을 넣어준후 xrdp 데몬 재시작 하면 해결됨

vi /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes


ubuntu server 데스크탑 환경 및 한글화

한글화를 위해 우선 로케일 설정
sudo apt install language-pack-ko
sudo locale-gen ko_KR.UTF-8

아래명령에서 ko_KR.UTF-8 설치후 선택
sudo dpkg-reconfigure locales

기본 명령 및 메시지까지 한글로 나오게 합
sudo update-locale LANG=ko_KR.UTF-8 LC_MESSAGES=ko_KR.UTF-8

또는 
vi /etc/default/locale
LANG="ko_KR.UTF-8"
LC_MESSAGES=ko_KR.UTF-8
LANGUAGE="ko:en"
LC_NUMERIC="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_PAPER="ko_KR.UTF-8"
LC_IDENTIFICATION="ko_KR.UTF-8"
LC_NAME="ko_KR.UTF-8"
LC_ADDRESS="ko_KR.UTF-8"
LC_TELEPHONE="ko_KR.UTF-8"
LC_MEASUREMENT="ko_KR.UTF-8"


이후 데스크탑 패키지 설치
sudo apt install ubuntu-desktop
sudo apt install ubuntu-gnome-desktop

데스크탑 로그온 후 부족한 한글 메시지 관련 패키지 추가 설치

2020년 3월 13일 금요일

vmware 에 guest 로 설치된 mac OS 해상도 조절

vmware workstation 이나 esxi 에 guest 로 mac OS를 설치 후 해상도 조절이 안되는 경우가 있습니다. vmware tools 를 설치하고 나서도 되지 않는데요
아래와 같은 명령어로 값을 수정후 재부팅 하면 해상도 조절이 자유롭게 됩니다.

 sudo defaults write /Library/Preferences/com.apple.windowserver.plist DisplayResolutionEnabled -bool false

com.apple.windowserver.plist 파일에 편집기로 해당값인 DisplayResolutionEnabled 값을 true => false 로도 수정가능하나
바이너리 타입이므로 텍스트 편집기론 수정 불가능합니다.

plist 전용 편집기도 있긴하지만 대부분 유료로 팔고 있어서 위와 같이 명령어로 설정하면 됩니다.

2019년 11월 17일 일요일

more locale2 adb 로 권한 주기

Show how to use 'pm' command 1. Enable USB debug mode 2. Connect to your PC and type below command. > adb shell pm grant jp.co.c_lis.ccl.morelocale android.permission.CHANGE_CONFIGURATION 3. Retry changing locale

2019년 11월 9일 토요일

adb 로 twrp 리커버리 쉽게 들어가기

샤오미 미패드2 의 경우에 전원키+볼륨하키 조합으로 리커버리 진입이 잘 안된다. 잘 될때가 없었던것 같다. 이럴때 개발자모드로 만든뒤에 USB 디버깅을 허용한다음에 adb를 이용하여 손쉽게 들어갈수 있다. adb reboot recovery

2019년 7월 12일 금요일

OEM PC에서 Windows Pro 버전

OEM PC나 노트북에 Windows10 Home 이 내장된 경우엔 아무리 Pro 로 설치를 하려고 해도 Pro 버전 선택이 되질 않습니다.

설치 USB 스틱에 /sources 디렉토리에 ei.cfg 파일을 만들어 넣으면 됩니다.

ei.cfg 파일 내용은 아래와 같습니다.



텍스트에디터로 위에 내용을 ei.cfg 로 저장해서 /sources 디렉토리에 넣으시면 됩니다.