查看IP
ifconfig
[root@localhost ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 52:54:00:8a:fe:e6 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.69 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::a00:27ff:fe94:9b6c prefixlen 64 scopeid 0x20<link>
ether 08:00:27:94:9b:6c txqueuelen 1000 (Ethernet)
RX packets 737 bytes 75483 (73.7 KiB)
RX errors 0 dropped 2 overruns 0 frame 0
TX packets 114 bytes 12081 (11.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 (Local Loopback)
RX packets 68 bytes 5912 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5912 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
這里修改 eth1
inet 192.168.10.69
id地址
netmask 255.255.255.0
子網(wǎng)掩碼
broadcast 192.168.10.255
廣播地址
修改eth1
- 進(jìn)入 /etc/sysconfig/network-scripts/
- 執(zhí)行l(wèi)s
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eth0 ifdown-ippp ifdown-sit ifup-bnep ifup-plusb ifup-TeamPort
ifcfg-eth1 ifdown-ipv6 ifdown-Team ifup-eth ifup-post ifup-tunnel
ifcfg-lo ifdown-isdn ifdown-TeamPort ifup-ippp ifup-ppp ifup-wireless
ifdown ifdown-post ifdown-tunnel ifup-ipv6 ifup-routes init.ipv6-global
ifdown-bnep ifdown-ppp ifup ifup-isdn ifup-sit network-functions
ifdown-eth ifdown-routes ifup-aliases ifup-plip ifup-Team network-functions-ipv6
- 打開配置文件
[root@localhost network-scripts]# vim ifcfg-eth1
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
BOOTPROTO=static #dhcp 動(dòng)態(tài)獲取IP static 靜態(tài)IP
#dhcp
ONBOOT=yes
DEVICE=eth1
NM_CONTROLLED=yes
DNS1=114.114.114.114 #DNS解析
IPADDR=192.168.10.69 #IP地址
NETMASK=255.255.255.0 #子網(wǎng)掩碼
GATEWAY=192.168.10.1 #網(wǎng)關(guān)
#VAGRANT-END
- wq保存退出
- 重啟網(wǎng)絡(luò)配置
1.在終端輸入:/etc/init.d/networ restart;
2.ifdown eth0 & ifup eth0;
3.ifconfig eth0 down & ifconfig eth0 up
備注:eth0是網(wǎng)卡的名字
- reboot 重啟linux
[root@localhost network-scripts]# reboot