配IP的时候学到的一点东西,简单做个记录。
//显示网络设备信息
#ifconfig
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.101.100.165 netmask 255.255.252.0 broadcast 10.101.103.255
inet6 fe80::3c77:1895:8f5a:b8fb prefixlen 64 scopeid 0x20<link>
ether 48:4d:7e:9d:2c:3f txqueuelen 1000 (以太网)
RX packets 609369204 bytes 82446450463 (82.4 GB)
RX errors 0 dropped 1595230 overruns 0 frame 0
TX packets 120691044 bytes 38299154001 (38.2 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 memory 0xf7000000-f7020000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 959781124 bytes 97628613847 (97.6 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 959781124 bytes 97628613847 (97.6 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
//启动、关闭指定网卡
# ifconfig eth0 down
# ifconfig eth0 up
//为网卡配置和删除IPv6地址
# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //为网卡设置IPv6地址
# ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //为网卡删除IPv6地址
//用ifconfig修改MAC地址
# ifconfig eth0 down //关闭网卡
# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址
# ifconfig eth0 up //启动网卡
//配置IP地址
# ifconfig eth0 192.168.1.56
//给eth0网卡配置IP地址
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0
// 给eth0网卡配置IP地址,并加上子掩码
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255