Ubuntu 18.04 上配置固定 IP
看以后 Ubuntu 的版本信息:
lsb_release -a
控制台显示:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
查看网卡:
ip addr
控制台显示:找到 ens33
。
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:21:34:93 brd ff:ff:ff:ff:ff:ff
inet 192.168.47.128/24 brd 192.168.47.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe21:3493/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:7e:96:88:8b brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
配置文件:/etc/network/interfaces
。
auto ens33
iface ens33 inet static
address 192.168.47.128
netmask 255.255.255.0
gateway 192.168.47.2
重启零碎 reboot
。