linux¾²Ì¬ipÔõôÉèÖÃ
linux ϵͳÖÐÉèÖþ²Ì¬ ip µØµãµÄ°ì·¨£ºÉó²éÍøÂç½Ó¿Ú£¨ip addr£©¡£±à¼ÍøÂçÉèÖÃÎļþ£¨sudo nano /etc/sysconfig/network-scripts/ifcfg-interface£©¡£ÉèÖþ²Ì¬ ip µØµã£¨ipaddr=£©¡£ÉèÖÃ×ÓÍøÑÚÂëºÍÍø¹Ø£¨netmask=¡¢gateway=£©¡£½ûÓà dhcp£¨onboot=no£©¡£ÉúÑĸü¸Ä²¢ÖØÆôÍøÂ磨sudo systemctl restart network£©¡£ÑéÖ¤ ip µØµã£¨ip addr£©¡£
ÔõÑùÉèÖà Linux ¾²Ì¬ IP µØµã
ÔÚ Linux ϵͳÖУ¬ÉèÖþ²Ì¬ IP µØµãºÜÊǼòÆÓ£¬Ö»ÐèÖ´ÐÐÒÔÏ°취£º
1. Éó²éÍøÂç½Ó¿Ú
Ê×ÏÈ£¬ÄãÐèҪȷ¶¨ÒªÉèÖþ²Ì¬ IP µØµãµÄÍøÂç½Ó¿Ú¡£¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁîÀ´Éó²é¿ÉÓõÄÍøÂç½Ó¿Ú£º
ip addr
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
½«Êä³öÀàËÆÓÚ£º
1: lo: <loopback> 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 2: eth0: <broadcast> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff</broadcast></loopback>
µÇ¼ºó¸´ÖÆ
ÔÚÕâÖÖÇéÐÎÏ£¬ÍøÂç½Ó¿ÚÊÇ eth0¡£
2. ±à¼ÍøÂçÉèÖÃÎļþ
½ÓÏÂÀ´£¬ÄãÐèÒª±à¼ /etc/sysconfig/network-scripts/ifcfg-INTERFACE Îļþ£¬ÆäÖÐ INTERFACE ÊÇÄãÒªÉèÖõÄÍøÂç½Ó¿ÚµÄÃû³Æ£¨ÔÚ±¾ÀýÖÐΪ eth0£©¡£
ʹÓÃÎı¾±à¼Æ÷·¿ªÎļþ£º
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
µÇ¼ºó¸´ÖÆ
3. ÉèÖþ²Ì¬ IP µØµã
ÔÚÎļþÖУ¬ÕÒµ½ÒÔÏÂÐУº
IPADDR=
µÇ¼ºó¸´ÖÆ
×÷·Ï×¢Ê͸ÃÐв¢ÊäÈëÄãҪʹÓõľ²Ì¬ IP µØµã£¬ÀýÈ磺
IPADDR=192.168.1.10
µÇ¼ºó¸´ÖÆ
4. ÉèÖÃ×ÓÍøÑÚÂëºÍÍø¹Ø
ͬÑù£¬ÕÒµ½ÒÔÏÂÐУº
NETMASK=
µÇ¼ºó¸´ÖÆ
GATEWAY=
µÇ¼ºó¸´ÖÆ
×÷·Ï×¢ÊÍÕâЩÐв¢ÊäÈëÏìÓ¦µÄ×ÓÍøÑÚÂëºÍÍø¹Ø£¬ÀýÈ磺
NETMASK=255.255.255.0 GATEWAY=192.168.1.1
µÇ¼ºó¸´ÖÆ
5. ½ûÓÃ DHCP
ΪÁËÈ·±£ÏµÍ³Ê¹Óþ²Ì¬ IP µØµã£¬ÄãÐèÒª½ûÓà DHCP¡£ÕÒµ½ÒÔÏÂÐУº
ONBOOT=no
µÇ¼ºó¸´ÖÆ
×÷·Ï×¢Ê͸ÃÐУ¬È·±£ËüÉèÖÃΪ no¡£
6. ÉúÑĸü¸Ä²¢ÖØÆôÍøÂç
ÉúÑÄÎļþ²¢Í˳öÎı¾±à¼Æ÷¡£È»ºó£¬Í¨¹ýÔËÐÐÒÔÏÂÏÂÁîÖØÐÂÆô¶¯ÍøÂ磺
sudo systemctl restart network
µÇ¼ºó¸´ÖÆ
7. ÑéÖ¤ IP µØµã
×îºó£¬Ê¹Óà ip addr ÏÂÁîÑéÖ¤ÊÇ·ñÒÑÉèÖþ²Ì¬ IP µØµã£º
ip addr
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
Êä³öÓ¦ÏÔʾËùÉèÖõľ²Ì¬ IP µØµã¡£
ÒÔÉϾÍÊÇlinux¾²Ì¬ipÔõôÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡