82143754 2020-04-29
# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.5254005aa781 yes virbr0-nic
如果需要修改的话,可以直接修改或者创建新的文件,然后使用下面命令来创建新的网络
virsh net-define 【filename】
virt-install --name linux-nat --ram 2048 --disk /data/linux.nat.raw --graphics vnc,port=5902 --network network=default,model=virtio--vcpus=8--os-variant=rhel6 --import
ifconfig virbr0 virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 52:54:00:5a:a7:81 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
进入虚拟机中,修改IP为192.168.122.2,网关为192.168.122.1
# iptables -A INPUT -p tcp --dport 8000 -j ACCEPT # iptables -t nat -A PREROUTING -d 61.155.xx.xxx -p tcp -m tcp --dport 8000 -j DNAT --to-destination 192.168.122.2:22 # iptables -t nat -A POSTROUTING -s 192.168.122.0/255.255.255.0 -d 192.168.122.2 -p tcp -m tcp --dport 22 -j SNAT --to-source 192.168.122.1