1-IP(OnBoot-Permanent)-dhcp-debian
vim /etc/network/interfaces
- auto eth0
- iface eth0 inet dhcp
sudo /etc/init.d/networking restart
2-IP(OnBoot-Permanent)-static-debian
vim /etc/network/interfaces
- auto eth0
- iface eth0 inet static
- address 192.168.50.2
- netmask 255.255.255.0
- gateway 192.168.50.1
- dns-nameservers 192.168.200.1
sudo /etc/init.d/networking restart
3-IP(OnBoot-Permanent)-dhcp-redhat
vim /etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE=eth0
- TYPE=Ethernet
- ONBOOT=yes
- BOOTPROTO=dhcp
- IPV4_FAILURE_FATAL=yes
- NAME="System eth0"
service network restart
or
nmcli dev disconnect ${device}
nmcli con reload ${device}
nmcli con up ${device}
4-IP(OnBoot-Permanent)-static-redhat
vim /etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE="eth0"
- BOOTPROTO=static
- ONBOOT=yes
- TYPE="Ethernet"
- IPADDR=192.168.50.2
- NAME="System eth0"
- HWADDR=00:0C:29:28:FD:4C
- GATEWAY=192.168.50.1
- [PEERDNS=no (then add DNS to /etc/resolv.conf)]
- or [DNS1=8.8.8.8] and
- [DNS2=8.8.4.4]]
service network restart
or
nmcli dev disconnect ${device}
nmcli con reload ${device}
nmcli con up ${device}
5-VirtualIP-(OnBoot-Permanent)-debian-static
vim /etc/network/interfaces [append]
- iface eth0:0 inet static
- address 123.123.22.22
- netmask 255.0.0.0
- broadcast 123.255.255.255
/etc/init.d/networking restart
6-VirtualIP-(OnBoot-Permanent)-debian-DHCP
vim /etc/network/interfaces [append]
/etc/init.d/networking restart
7-virtualIP-(OnBoot-Permanent)-Redhat-static
vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
- DEVICE=eth0:0
- IPADDR=123.123.22.22
- NETMASK=255.0.0.0
- NETWORK=123.0.0.0
- BROADCAST=123.255.255.255
- ONBOOT=yes
service network restart
or
nmcli dev disconnect ${device}
nmcli con reload ${device}
nmcli con up ${device}
8-virtualIP-(OnBoot-permanent)-Redhat-DHCP
vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
- DEVICE=eth0:0
- BOOTPROTO=dhcp
- ONBOOT=yes
service network restart
or
nmcli dev disconnect ${device}
nmcli con reload ${device}
nmcli con up ${device}
9-IP(Not permanent)-ifconfig
- ifconfig -a #show all Interface and details
- ifconfig enp6s0 down #set off interface
- ifconfig enp6s0 up #set on interface
- ifconfig enp6s0 192.168.2.24 #set ip to interface
- ifconfig enp6s0 netmask 255.255.255.0 #set subnetmask
- ifconfig enp6s0 mtu 9000 #set mtu
- ifconfig enp6s0:0 192.168.2.25 #set secondary ip (virtual)
- ifconfig eth0:0 down #set off virtual ip
-
10-IP(Not permanent)-ip
- ip a #show all Interface and details
- ip link set eth0 down #set Off interface
- ip link set eth0 up #set on interface
- ip addr add 192.168.2.24/24 dev eth0 #set ip to interface
- ip link set eth0 mtu 9000 #set mtu
- ip addr del 192.168.1.1/24 dev eth0 #set Off interface
- ip addr show eth0
نکته: از دستور زیر برای استفاده در توزیعهای ردهت استفاده میشود:
system-config-network-tui
نکتنه: میتوانیم با دستور زیر برنامهای در CentOS6 نصب کنیم تا بتوانیم توسط آن کارت شبکه را تنظیم نماییم:
yum intall system-config-network