ubuntu17配置固定IP静态IP

$ ifconfig
docker0: flags=4099  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::42:e7ff:fe37:b3c1  prefixlen 64  scopeid 0x20
        ether 02:42:e7:37:b3:c1  txqueuelen 0  (以太网)
        RX packets 8453  bytes 1371909 (1.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9763  bytes 23399848 (23.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker_gwbridge: flags=4163  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::42:78ff:fe10:72fa  prefixlen 64  scopeid 0x20
        ether 02:42:78:10:72:fa  txqueuelen 0  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7480  bytes 1050620 (1.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0: flags=4163  mtu 1500
        inet 192.168.0.105  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20f:4de4:74a0:2e04  prefixlen 64  scopeid 0x20
        ether 1c:1b:0d:c2:54:bd  txqueuelen 1000  (以太网)
        RX packets 514393  bytes 560697470 (560.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 320009  bytes 37329723 (37.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (本地环回)
        RX packets 484166  bytes 145914963 (145.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 484166  bytes 145914963 (145.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethcd4e106: flags=4163  mtu 1500
        inet6 fe80::6870:d7ff:feef:6932  prefixlen 64  scopeid 0x20
        ether 6a:70:d7:ef:69:32  txqueuelen 0  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11380  bytes 1391320 (1.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sudo vi /etc/modprobe.d/blacklist.conf   # 在文件末尾加上`blacklist ipv6`
tail -1 /etc/modprobe.d/blacklist.conf

blacklist ipv6

sudo ifconfig enp2s0 192.168.0.125 netmask 255.255.255.0
sudo route add default gw 192.168.0.1
sudo service network-manager restart
sudo vi /etc/network/interfaces  # 在文件末尾加上 `dns-nameservers 8.8.8.8 8.8.4.4`
tail -1 /etc/network/interfaces

dns-nameservers 8.8.8.8 8.8.4.4

sudo reboot




你可能感兴趣的:(Linux)