Skip to content

Ubuntu 设置网卡IP

列网口

ifconfig -s # to list network interfaces

# just show eth0
ifconfig -v eth0 

列网关

route -n

临时改IP


ifconfig -v eth0 192.168.1.123 255.255.255.0   # interface IP Mast
route add default gw 192.168.1.1 # gateway

系统网络配置文件 – /etc/network/interfaces

#The primary network interface - use DHCP to find our address
auto eth0

# using dhcp
iface eth0 inet dhcp

# using static
iface eth1 inet static
address 192.168.1.123
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 1.1.1.1 8.8.8.8
# ipv6
up ip addr add 您的IPV6地址/64 dev eth0
up ip -6 route add 你的IPV6网关 dev eth0
up ip -6 route add default via 你的IPV6网关
# The Google Public DNS IPv6 addresses are as follows:
#2001:4860:4860::8888
#2001:4860:4860::8844

重启网络

sudo service networking restart
# or
/etc/init.d/networking restart

ifdown eth0 && ifup eth0

Leave a Reply

Your email address will not be published.