linux机器添加网络段

2017-11-02  本文已影响0人  晨暮云海

Ubuntu 加网段:
Ifconfig ens160:0 30.0.0.2/24
修改:/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160
iface ens160 inet static
address 10.0.0.120
netmask 255.255.255.0

gateway 10.0.0.1
dns-nameservers 114.114.114.114

iface ens160:0 inet static
address 30.0.0.2
netmask 255.255.255.0

centos加网段:
ifconfig ens192:1 30.0.0.5 netmask 255.255.255.0
cd /etc/sysconfig/network-scripts/
Cp ifcfg-ens192 ifcfg-ens192:1

vi ifcfg-ens192:1

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192:1
DEVICE=ens192:1
ONBOOT=yes
IPADDR=30.0.0.5
NETMASK=255.255.255.0

centos 删除ip:

删除网卡的第二个IP地址:
ip addr del 192.168.0.1 dev eth0

重启网关

sudo /etc/init.d/networking restart
sudo ifdown eth0
sudo ifup eth0

修改网关:

route del default 删除默认网关
添加新网关:route add default gateway 10.0.0.1
route -n 查看路由表
man route 查看route用法

CentOS
网络拨号:

pppoe-stop
pppoe-start
上一篇下一篇

猜你喜欢

热点阅读