1.查看
ifconfig
2.一个网卡配置多个ip
修改/etc/network/interfaces
文件
auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.63.41
netmask 255.255.255.0
auto enp0s31f6:0
iface enp0s31f6:0 inet static
address 192.168.1.11
netmask 255.255.255.0
3.查看网关
netstat -rn 或 route -n
内核 IP 路由表
Destination Gateway Genmask Flags MSS Window irtt Iface
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 enp0s31f6
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s31f6
192.168.63.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s31f6
4.添加路由
route add default gw 192.168.63.63 (临时有效)
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.63.63 0.0.0.0 UG 0 0 0 enp0s31f6
网关地址可以在/etc/network/interfaces文件中配置(重启不会失效)
gateway 192.168.63.63
5.添加DNS
/etc/resolv.conf文件加上(临时有效果)
nameserver 8.8.8.8
dns地址可以在/etc/network/interfaces文件中配置(重启不会失效)
dns-nameserver 8.8.8.8