russel053/ 十一月 18, 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 enp1s0 mtu 9000 && ifconfig enp1s0d1 mtu 9000

Proxmox 免重開機生效IP:

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

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

nano /etc/netplan/01-netcfg.yaml

範例:
network:
  version: 2
  renderer: networkd
  ethernets:
    ens18:
       addresses: [10.0.1.61/24]
       gateway4: 10.0.1.1
       nameservers:
         addresses: [1.1.1.1,8.8.8.8]

設定好之後測試:

sudo netplan --debug generate

執行:

netplan apply

Raspberry Pi:

/etc/dhcpcd.conf

interface eth0
static ip_address=10.0.1.106
static routers=10.0.1.1
static domain_name_servers=1.1.1.1
Share this Post