openstack虚机路由配置
时间:2023-06-27 18:09:01 | 来源:网站运营
时间:2023-06-27 18:09:01 来源:网站运营
openstack虚机路由配置:最近需要在openstack的实例虚机配置公网网卡,网卡信息配置无误。
208 vi ifcfg-eth0
209 vi ifcfg-eth1
210 vi ifcfg-eth2
211 route show
212 route -n
213 vi ifcfg-eth2
214 vi ifcfg-eth1
215 vi ifcfg-eth0
216 systemctl status sshd
BOOTPROTO=static
DEFROUTE=yes
DEVICE=eth1
GATEWAY=219.128.180.65
IPADDR=219.128.180.70
MTU=1500
NETMASK=255.255.255.192
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:b8:25:55 brd ff:ff:ff:ff:ff:ff
inet 172.81.201.40/24 brd 172.81.201.255 scope global noprefixroute dynamic eth0
valid_lft 61947sec preferred_lft 61947sec
inet6 fe80::f816:3eff:feb8:2555/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:64:6d:fc brd ff:ff:ff:ff:ff:ff
inet 219.128.180.70/26 brd 219.128.180.127 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe64:6dfc/64 scope link
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:40:27:3c brd ff:ff:ff:ff:ff:ff
可是openstack内部网络互访正常,外网无法访问公网,ping不同。
说明虚机网卡信息没有出去集群到交换机的路由表上。于是添加静态路由,引导虚机路由扩散。
170 route add -net 192.0.0.0/8 gateway 172.81.201.1 dev eth0
171 route add -net 172.0.0.0/8 gateway 172.81.201.1 dev eth0
174 route add -net 10.0.0.0/8 gateway 172.81.201.1 dev eth0
最后 systemctl restart network 就成功外网访问
需要sshd固定端口,则修改
vi /etc/ssh/sshd_config
systemctl restart sshd