2018年5月12日 星期六

Docker 安裝流程

Add default user to sudo group :

su
apt -y install sudo
usermod -a -G sudo "username"
logout
id


Docker Install :

sudo apt-get install -y \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
     $(lsb_release -cs) \
stable"
sudo apt update -y
sudo apt install -y docker-ce
sudo usermod -a -G docker "username"

2018年4月30日 星期一

Linux 網路卡問題排錯 - IP

在 Linux/Unix 底下有幾個關於 IP 配置指令 :

ifconfig - 一般用於配置 IP , Netmask
# ifconfig eth0 192.168.1.1/24
# ifconfig eth0
eth0: flags=4163  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 00:50:b1:03:a1:00  txqueuelen 1000  (Ethernet)
        RX packets 321985  bytes 415032409 (395.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 185822  bytes 19749935 (18.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
route - 調整路由
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.254   0.0.0.0         UG    100    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0
ip - 跟 ip 有關係的都可以透過此指令
# ip route show
default via 192.168.1.1 dev eth0  proto static  metric 100
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1  metric 100
# ip neigh show
192.168.1.254 dev eth0 lladdr 00:50:b1:03:a1:01 REACHABLE
# ip link show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:b1:03:a1:00 brd ff:ff:ff:ff:ff:ff
# ip rule show
0: from all lookup local
32766: from all lookup main
32767: from all lookup default

Linux 網路卡問題排錯 - 實體層

ethtool - 調整傳輸設定(定速, 全雙工/半雙工, 光功率診斷/設定, 無線網路強度診斷...)
# ethtool enp4s0f2
Settings for eth0:
 Supported ports: [ TP MII ]
 Supported link modes:   10baseT/Half 10baseT/Full
                         100baseT/Half 100baseT/Full
                         1000baseT/Half 1000baseT/Full
 Supported pause frame use: No
 Supports auto-negotiation: Yes
 Advertised link modes:  10baseT/Half 10baseT/Full
                         100baseT/Half 100baseT/Full
                         1000baseT/Half 1000baseT/Full
 Advertised pause frame use: Symmetric Receive-only
 Advertised auto-negotiation: Yes
 Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                      100baseT/Half 100baseT/Full
 Link partner advertised pause frame use: Symmetric
 Link partner advertised auto-negotiation: Yes
 Speed: 100Mb/s
 Duplex: Full
 Port: MII
 PHYAD: 0
 Transceiver: internal
 Auto-negotiation: on
 Supports Wake-on: pumbg
 Wake-on: g
 Current message level: 0x00000033 (51)
          drv probe ifdown ifup
 Link detected: yes

mii-tool - 調整傳輸設定(定速, 更改 MAC, 更改允許速度)

# mii-tool -v enp4s0f2
enp4s0f2: negotiated 1000baseT-HD flow-control, link ok
  product info: vendor 00:07:32, model 17 rev 5
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD