网络拓扑结构如下:
自己画的,请勿盗用!
先连接主机c1与路由器R1
R1前面已经启动,现在启动c1
sudo lxc start c1
创建网络并绑定端口
sudo lxc network create C1R1 ipv6.address=none ipv4.address=12.12.12.1/24
sudo lxc network attach C1R1 c1 eth0
sudo lxc network attach C1R1 R1 eth0
进入R1
sudo lxc exec R1 bash
分配地址
root@R1:~# ip addr add 12.12.12.2/24 dev eth0
启动网卡
root@R1:~# ip link set eth0 up
查看网卡配置
root@R1:~# ip addr
退出容器
root@R1:~# exit
进入c1
sudo lxc exec c1 bash
分配地址
root@c1:~# ip addr add 12.12.12.1/24 dev eth0
启动网卡
root@c1:~# ip link set eth0 up
替换默认网关
root@c1:~# route delete def