Ubuntu-16.04.2-Server配置網路卡IP

dbasdk發表於2017-06-09

root@ubuntu:/etc/network# vi /etc/network/interfaces

root@ubuntu:/etc/network# cat /etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

 

source /etc/network/interfaces.d/*

 

# The loopback network interface

auto lo

iface lo inet loopback

 

# The primary network interface

auto ens33

iface ens33 inet dhcp            #自動獲取IP的設定

 

auto ens38

iface ens38 inet static

address 192.168.3.166

netmask 255.255.255.0          #固定IP的設定

 

auto ens39

iface ens39 inet dhcp            #自動獲取IP的設定

root@ubuntu:/etc/network# ifconfig -a| grep inet

          inet addr:192.168.142.12  Bcast:192.168.142.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d40/64 Scope:Link

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

root@ubuntu:/etc/network# systemctl restart networking.service     #重啟網路服務

root@ubuntu:/etc/network# ifconfig -a| grep inet

          inet addr:192.168.142.12  Bcast:192.168.142.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d40/64 Scope:Link

          inet addr:192.168.3.166  Bcast:192.168.3.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d4a/64 Scope:Link

          inet addr:192.168.1.6  Bcast:255.255.255.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d54/64 Scope:Link

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

root@ubuntu:/etc/network# ifconfig -a

ens33     Link encap:Ethernet  HWaddr 00:0c:29:e9:9d:40 

          inet addr:192.168.142.12  Bcast:192.168.142.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d40/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:6164 errors:0 dropped:0 overruns:0 frame:0

          TX packets:549 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:403243 (403.2 KB)  TX bytes:72747 (72.7 KB)

 

ens38     Link encap:Ethernet  HWaddr 00:0c:29:e9:9d:4a 

          inet addr:192.168.3.166  Bcast:192.168.3.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d4a/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 B)  TX bytes:648 (648.0 B)

 

ens39     Link encap:Ethernet  HWaddr 00:0c:29:e9:9d:54 

          inet addr:192.168.1.6  Bcast:255.255.255.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fee9:9d54/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:7 errors:0 dropped:0 overruns:0 frame:0

          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1678 (1.6 KB)  TX bytes:1332 (1.3 KB)

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:160 errors:0 dropped:0 overruns:0 frame:0

          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1

          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

 

root@ubuntu:/etc/network#

root@ubuntu:/etc/network# ping 192.168.3.166

PING 192.168.3.166 (192.168.3.166) 56(84) bytes of data.

64 bytes from 192.168.3.166: icmp_seq=1 ttl=64 time=0.014 ms

^C

--- 192.168.3.166 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 0.014/0.014/0.014/0.000 ms

root@ubuntu:/etc/network# ping 192.168.1.6

PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.

64 bytes from 192.168.1.6: icmp_seq=1 ttl=64 time=0.034 ms

^C

--- 192.168.1.6 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 0.034/0.034/0.034/0.000 ms

root@ubuntu:/etc/network# 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-2140557/,如需轉載,請註明出處,否則將追究法律責任。

相關文章