背景
同一台笔记本,一个网卡,公司需设置固定IP,回家需切换DHCP,咋整?
解决方案:配置网卡多会话功能
约定
- 公司的会话:company
- 家里的会话:home
添加公司会话
# nmcli connection add con-name company type ethernet ifname eno16777736
Connection 'company' (d6f93284-24cf-478f-9c22-cf86dedbd234) successfully added.
添加居家会话
# nmcli connection add con-name home type ethernet ifname eno16777736 autoconnect no ip4 192.168.11.30/24 gw4 192.168.11.1
Connection 'home' (d0f4fd31-23ec-482b-9337-bef1cade04c1) successfully added.
切换到公司会话
# nmcli comnection up company
同一时间,只能有一个会话处于激活状态
查看会话信息
# nmcli connection show
NAME UUID TYPE DEVICE
home d0f4fd31-23ec-482b-9337-bef1cade04c1 802-3-ethernet --
company d6f93284-24cf-478f-9c22-cf86dedbd234 802-3-ethernet eno16777736
eno16777736 4d406f2a-5fa3-438b-ab3f-fcdbe5c0a50d 802-3-ethernet --