ifconfig


/etc/init.d/networking restart

vi /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp




 

 

 

 

https://blog.csdn.net/robacco/article/details/79238166

https://blog.csdn.net/ly2020_/article/details/89330404

 

ifconfig eth0 192.168.80.111 netmask 255.255.255.0

route add default gw 192.168.80.2

 




ifconfig eth0 10.0.2.15 netmask 255.255.255.0

route add default gw 10.0.2.2
 


 

auto lo
iface lo inet loopback
 

auto eth0  

iface eth0 inet dhcp



 

https://blog.csdn.net/weixin_43314056/article/details/83347296



linux系统设置静态IP,DHCP网络服务,DNS

 

一、设置静态IP及DHCP网络服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
kk@yuanqiangfei:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto eth0                                                #eth0网卡开机启动
iface eth0 inet dhcp                                    #使用DHCP服务器申请动态IP
#iface eth0 inet static                                 #设置eth0网卡静态IP
#address 192.168.1.188                               #静态IP  
#netmask 255.255.255.0                               #掩码
#gateway 192.168.1.1                                  #网关  

二、修改DNS 

1
2
3
4
5
kk@yuanqiangfei:~$ cat /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.3.1
nameserver 192.168.1.1
kk@yuanqiangfei:~$ ^C
kk@yuanqiangfei:~$ resolvconf -u

查看修改是否成功: 

修改相关参数之后重启网络:

1
sudo service networking restart

 

 

 

 

 

 

localhost:~# ifconfig
eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:192.168.122.76 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:15 dropped:0 overruns:0 frame:15
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1331 (1.2 KiB) TX bytes:1675 (1.6 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

localhost:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.122.1 0.0.0.0 UG 202 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 eth0

 

 

 


-net nic -net tap,ifname=tap3,script=no,downscript=no


run_cmd () {
$*
if [ $? -ne 0 ]; then
echo "command $* failed"
exit 1
fi
}

run_cmd "ip tuntap add $GUEST_TAP_NAME mode tap user `whoami`"
run_cmd "ip link set $GUEST_TAP_NAME up"
run_cmd "ip link set $GUEST_TAP_NAME master virbr0"

echo "-device e1000,mac=${GUEST_MAC_ADDR},netdev=net0 -netdev tap,id=net0,ifname=${GUEST_TAP_NAME},script=no,downscript=no"

run_cmd "ip tuntap del ${GUEST_TAP_NAME} mode tap"

ifconfig eth0 192.168.122.78 netmask 255.255.255.0
route add default gw 192.168.122.1




vi /etc/resolv.conf
nameserver 114.114.114.114



ping www.baidu.com


ifconfig eth0 10.0.2.15 netmask 255.255.255.0
route add default gw 10.0.2.2

vi /etc/resolv.conf
nameserver 114.114.114.114







KEYMAPOPTS="us us"

# Set hostname to alpine-test
HOSTNAMEOPTS="-n hyperchain"

# Contents of /etc/network/interfaces
INTERFACESOPTS="auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.0.2.15
netmask 255.255.255.0
gateway 10.0.2.2
"

# Search domain of example.com, Google public nameserver
DNSOPTS="-d hyperchain.com 114.114.114.114"

# Set timezone to UTC
TIMEZONEOPTS="-z PRC"

# set http/ftp proxy
PROXYOPTS="none"

# Add a random mirror

# Install Openssh
SSHDOPTS="-c openssh"

# Use openntpd
NTPOPTS="-c openntpd"





# Use /dev/sda as a data disk
#DISKOPTS="-m data /dev/sda"

# Setup in /media/sdb1
#LBUOPTS="/media/sdb1"
#APKCACHEOPTS="/media/sdb1/cache"








qemu-kvm -enable-kvm -cpu host -smp 2,maxcpus=64 -m 2048M,slots=5,maxmem=30G  -drive if=pflash,format=raw,unit=0,file=./OVMF_CODE.fd,readonly -hda a.img -nographic -monitor pty -cdrom
qemu-kvm -enable-kvm -cpu host -smp 2,maxcpus=64 -m 2048M,slots=5,maxmem=30G -drive if=pflash,format=raw,unit=0,file=./OVMF_CODE.fd,readonly -hda ./a.img -object sev-guest,id=sev0,policy=1073741825,cbitpos=47,reduced-phys-bits=5 -machine memory-encryption=sev0 -name guest=csv-t1 -nographic -monitor pty -net nic -net tap,ifname=tap3,script=no,downscript=no


posted @ 2021-04-14 14:52  zJanly  阅读(106)  评论(0编辑  收藏  举报