Posts tagged with “linux”

Vmware CentOS guest IP address automatically changed Isuse

今天天气不错,和太太儿子去 Bowenvale Walking Tracks 走了一个短途的hiking。回家路上前端同学报告说测试机出问题了,所有接口都不通了。于是到家赶紧排查问题。

网络环境

Host:Windows 10,Vmware Station Guest: CentOS 7.7 Bridge network

一开始以为是服务进程崩了。连上vpn发现机器都ping不通。哦看来虚拟机是被谁关掉了。远程桌面到Host机器一看....虚拟机活得好好的,并没有被关掉。用控制台登录进去一看,发现IP不是我们以前设定的IP,而是变成 172.18.开头的一个地址,这是我们误以为网络不通了的原因。

经过一番排查,发现故事应该是这样的:

CentOS机器的网络配置是 DHCP,因为网络是桥接的,因此只需要路由器上做点设置,根据CentOS机器网卡的Mac地址总是分配 192.168.178.52 这个IP给虚拟机就行了。我查看了路由器的设置,发现确实是这么设置的,虚拟机网卡的mac地址也没有变,看上去一切都很正常。不过这里有一个小小的细节,一开始我没有在意,但它可能是问题发生的始作俑者。

在登录公司路由器的时候,我没有直接进入设置界面,而是系统弹出一个提示框,说系统刚刚升级到某某版本,有一个引导界面走了好几步才进入路由器设置界面。

我先是修改CentOS的网络设置,把网络参数由 dhcp 改成 static,确保他总是使用 192.168.178.52 这个IP,也设置了默认路由,重启网络,发现修改生效了,IP地址现在是正确的了,但是却不能上网,内外不通。

那问题出在哪里呢?之前拿到的IP是172.18.x.x,这不是 Docker 喜欢用的IP段么?莫非和Docker 有关?我先是把 CentOS 虚拟机里的Docker 停掉....重启网络,依然固我。网还是不通。

我只好把关注点移到 Host 机器,硬件网卡,VMnet1, VMnet8, vEthernet (Default Switch)..... 慢,这个vEthernet 是什么鬼? 它的IP也是172.18.x.x的!网上搜索了一下,说这个东东应该是Docker添加的。对呀,我前几天刚好干过这个事情,在Windows 10 上安装了Docker,那时我是试图解决 Jenkins 不听话的问题。但因为这台Windows 10 主要是兄弟部门在用,怕Docker影响他们的业务,我的经理就赶紧把Docker卸掉了。

Docker都卸掉了,卸掉这个虚拟网络示配器料无大碍,于是我就尝试 uninstall it。系统提示发生了什么未知的错误,不让卸载。那就禁用它吧。禁用成功。再ping那个IP,网通了!

回头想想,CentOS机器的IP并非无缘无故就变了,我猜测应该是路由器自动升级,在那个短暂离线期间,CentOS的网络被我刚刚禁用的那个虚拟switch抢先接管了。本来应该由路由器固定分配 192.168.178.52 给那台机器,但路由器短暂弃权期间,这个过程被那个虚拟的switch示配器干扰,于是CentOS得到一个 172.18 开头的IP。

哎!Docker也真是的,你都已经被卸掉了,也不把自己带的东西清理干净。

很有意思的排错过程,记录下。

My favorite applications on Ubuntu

Awesome-Linux-Software
Awesome-Linux-Software Chinese

Currently, my laptop runs Pop! OS 18.04 (Ubuntu). Thanks my boss, he bought me a Windows laptop, so I have the chance to run Linux as my main OS. The following is a list of my favorite apps on my laptop.

mp3 player: Audacious

browser: Chromium

Markdown editor: Typora

Text editor: Geany

Quick view: gnome-sushi

Epub reader: Foliate

Console Dictionary: sdcv

Console tts: say (in gnustep-gui-runtime package)

hardware information: inxi

say alternative: gnustep-gui-runtime

apt-get install -y audacious chromium typora geany gnome-sushi foliate sdcv gnustep-gui-runtime inxi

3rd software

Jetbrains: Rider, Webstorm, Phpstorm, Pycharm

Telegram-desktop

will update the list when I remember... 😀

gnome3 how to alt tab windows on current workspace only?

gsettings set org.gnome.shell.app-switcher current-workspace-only true

Virtualbox MacOS VM setup / setup Rime/Squirrel input method (鼠须管) on macOS

  1. I successfully ran macOS High Sierra on my Ubuntu 18.04 laptop through VirtualBox. VirtualBox is great ! This article helps!
  2. Install Rime on macOS in five minutes
    1. download the zip file from latest release from the Tags page on GitHUB
    2. unzip the file and install the pkg file
    3. go to https://github.com/rime/plum to get the wubi package.
git clone https://github.com/rime/plum.git
cd plum
bash rime-install wubi pinyin-simp

The last step, is creating a default.custom.yaml file and putting it in ~/Library/Rime directory.

the content in my default.custom.yaml is

patch:
  schema_list:
    - schema: wubi_pinyin
    - schema: pinyin_simp

How make openvpn work with docker & avoid entering the password every time

I met this issue today morning and find the solution from the link I just refered.

I have made a few change to the solution to meet my case, this is why I wrote this article.

My version of fix-routes.sh

#!/bin/sh
echo "Adding custom route to $route_vpn_gateway with /24 mask..."
# ip route add 10.8.0.0/24 via $route_vpn_gateway
ip route add 192.168.178.0/24 via $route_vpn_gateway

echo "Removing /1 routes..."
ip route del 0.0.0.0/1 via $route_vpn_gateway
ip route del 128.0.0.0/1 via $route_vpn_gateway

I didn't use ip route add default via $route_vpn_gateway line because I didn't want to route everything through my VPN.

Changes to my openvpn profile

You can see I added an extra askpass line besides what the author has done. That line was added to help me get ride of the annoyance of entering the password for my private key every time I run the openvpn client program.

auth SHA256
auth-nocache
verb 3
askpass /home/davidwei/ovpn/pass.txt
script-security 2
route-up /etc/openvpn/fix-routes.sh

My ovpn start one-line script

davidwei@xps:~$ cat ~/bin/ovpn 
sudo openvpn ~/shukebeta.ovpn > /dev/null 2>&1 &

My pass.txt

davidwei@xps:~$ cat ~/ovpn/pass.txt 
my-very-secret-password