russel053/ 18 11 月, 2017/ 網路, 網路服務

如果沒有內建:

apt install lshw

檢查網卡名稱:

lshw -c network

顯示如下:

*-network:12
       description: Ethernet interface
       physical id: f
       bus info: [email protected]:06:00.0
       logical name: enp6s0
       serial: 00:02:c9:33:01:f0
       capabilities: ethernet physical fibre
       configuration: autonegotiation=off broadcast=yes driver=mlx4_en driverversion=4.0-0 firmware=2.42.5000 link=no multicast=yes port=fibre

其中 logical name: enp6s0 就是網卡ID,或者用此方法:

lspci |grep Ethernet
19:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
19:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)


dmesg |grep 19:00
igb 0000:19:00.0 ens10f0: renamed from eth0
igb 0000:19:00.1 ens10f1: renamed from eth2

nano /etc/network/interface

範例:
auto eth0
iface eth0 inet static
address 10.0.1.104
netmask 255.255.255.0
gateway 10.0.1.1
dns-nameservers 1.1.1.1 168.95.192.1

nano /etc/resolv.conf
nameserver 1.1.1.1

MTU9000:

#OVS Setting:
mtu 9000
pre-up ( ifconfig enp1s0 mtu 9000 && ifconfig enp1s0d1 mtu 9000)
#Linux Bridge:
post-up ifconfig ens4 mtu 9000 && ifconfig ens4d1 mtu 9000
#ip link Set(新版方式)
pre-up ip link set ens4 mtu 9000
#bond 在 pre-up 下一行新增
post-up ip link set bond0 mtu 9216

Proxmox 免重開機生效IP:

mv /etc/network/interfaces.new /etc/network/interfaces
systemctl restart networking

Ubuntu 17.10之後不再支援靜態IP改用以下方法固定:

nano /etc/netplan/50-cloud-init.yaml

範例:
network:
    ethernets:
        ens18:
            addresses: [10.0.1.108/24]
            gateway4: 10.0.1.1
            nameservers:
              addresses: [10.0.1.1,1.1.1.1]
            dhcp4: no
    version: 2

設定好之後測試:

sudo netplan --debug generate

執行:

netplan apply

Raspberry Pi:

關閉Wifi/BT:

nano /boot/config.txt

dtoverlay=disable-wifi
dtoverlay=disable-bt

#列出WiFi/BT開關狀態清單
rfkill list
#關閉WiFi/BT(軟關閉)
rfkill block wifi
rfkill block bluetooth

Static IP 設置:

/etc/dhcpcd.conf

interface eth0
static ip_address=10.0.1.106/24
static routers=10.0.1.1
static domain_name_servers=1.1.1.1

NanoPi WiFi/BT(NMCLI皆適用):

#切換到root賬戶
su root
#查看網絡設備列表
nmcli dev
#注意,如果列出的設備狀態是 unmanaged 的,說明網絡設備不受NetworkManager管理,你需要清空 /etc/network/interfaces下的網絡設置,然後重啓.
#開啓WiFi
nmcli r wifi on
#掃描附近的 WiFi 熱點
nmcli dev wifi
#連接到指定的 WiFi 熱點
nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0
#請將 SSID和 PASSWORD 替換成實際的 WiFi名稱和密碼。連接成功後,下次開機,WiFi也會自動連接。
#設定固定ip
nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 10.0.1.93/24 ipv4.gateway 10.0.1.1 ipv4.dns 10.0.1.1
#查看連接狀態
nmcli connection show

 

Share this Post