該配置環境為ubuntu16.04.2
(一) 網絡配置
安裝完成系統后網絡配置如下:
第一步:ifconfig -a 查看有幾個網卡
如下截圖表示有四個網卡
第二步:找出接線網卡
執行命令:ifconfig +網卡 up
例:up 第一個網卡enp4s0f0
ifconfig enp4s0f0 up
然后執行命令: ethtool enp4s0f0? 查看Link狀態,如下截圖:
如果是yes表示該網卡已經接線 ,嘗試手動配置ip(配置方法請見下一步驟)。如果是no,繼續ifconfig up其他網卡,直到找到yes的為止。如果全部是no,請檢查網線是否接好
第三步:配置網卡ip(只有臨時作用,再次重啟服務器配置會失效)
命令:ifconfig enp11s0f1 10.57.23.13/25
說明:配置網卡 enp11s0f1? IP為10.57.23.13 掩碼是25位。即255.255.255.128
配置好截圖如下:
第四步:檢測連通性
嘗試ping 網關,如果網關不通,表示直連不通,請檢查網線和配置。網關通,接著配置默認路由,見第五步
第五步:配置路由(臨時,重啟后失效)
route add default gw 10.57.23.1 (默認配置這一條后,內網可以正常訪問),如果不能,添加如下明細:
route add -net 10.0.0.0/8 gw 10.57.23.1
route add -net 192.168.0.0/16 gw 10.57.23.1
route add -net 172.16.0.0/12 gw 10.57.23.1
route add -net 100.64.0.0/10 gw 10.57.23.1
第六步:寫入配置文件(永久)
注:一定要寫入配置文件
ubuntu為何不直接在最開始寫入配置文件里。因為ubuntu直接寫入配置文件,不重啟服務器貌似不生效(個人經驗)
vim /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 enp11s0f1? ? ?
iface enp11s0f1 inet static
address 10.57.23.13
netmask 255.255.255.128
gateway 10.57.23.1
####添加路由,這樣網卡服務重啟之后這些路由就會加載
up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.57.23.1
up route add -net 192.168.0.0 netmask 255.255.0.0 gw 10.57.23.1
up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.57.23.1
up route add -net 100.64.0.0 netmask 255.192.0.0 gw 10.57.23.1
重啟網卡服務之后,配置的路由會自動加載,如下:
(二) 修改ssh 配置文件
ubuntu系統安裝,默認是禁止root直接登錄的
vim /etc/ssh/sshd_config
修改:PermitRootLogin yes
然后重啟ssh服務 /etc/init.d/ssh restart